mount: cleanup error() and die()
* moves error() and die() to sundries.h * removes at_die * adds __attribute__ ((__format__ (__printf__ ))) Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
ab9dd9385c
commit
26f95c7da2
|
@ -813,7 +813,6 @@ update_mtab (const char *dir, struct my_mntent *instead) {
|
|||
|
||||
/* dummy */
|
||||
int verbose;
|
||||
int mount_quiet;
|
||||
char *progname;
|
||||
|
||||
const char *fsprobe_get_label_by_devname(const char *spec) { return NULL; }
|
||||
|
|
|
@ -50,9 +50,6 @@
|
|||
#include "setproctitle.h"
|
||||
#endif
|
||||
|
||||
/* Quiet mode */
|
||||
int mount_quiet = 0;
|
||||
|
||||
/* True for fake mount (-f). */
|
||||
static int fake = 0;
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "xmalloc.h"
|
||||
#include "nls.h"
|
||||
|
||||
int mount_quiet;
|
||||
|
||||
char *
|
||||
xstrndup (const char *s, int n) {
|
||||
char *t;
|
||||
|
@ -108,6 +110,19 @@ error (const char *fmt, ...) {
|
|||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
/* Fatal error. Print message and exit. */
|
||||
void
|
||||
die(int err, const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
|
||||
exit(err);
|
||||
}
|
||||
|
||||
/* True if fstypes match. Null *TYPES means match anything,
|
||||
except that swap types always return false. */
|
||||
/* Accept nonfs,proc,devpts and nonfs,noproc,nodevpts
|
||||
|
|
|
@ -22,9 +22,14 @@ extern int sloppy;
|
|||
|
||||
#define streq(s, t) (strcmp ((s), (t)) == 0)
|
||||
|
||||
/* Functions in sundries.c that are used in mount.c and umount.c */
|
||||
/* Functions in sundries.c that are used in mount.c and umount.c */
|
||||
void block_signals (int how);
|
||||
void error (const char *fmt, ...);
|
||||
|
||||
void error (const char *fmt, ...)
|
||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
void die(int err, const char *fmt, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
|
||||
int matching_type (const char *type, const char *types);
|
||||
int matching_opts (const char *options, const char *test_opts);
|
||||
void *xmalloc (size_t size);
|
||||
|
@ -35,8 +40,6 @@ char *xstrconcat4 (char *, const char *, const char *, const char *);
|
|||
|
||||
int parse_spec(const char *spec, char **name, char **value);
|
||||
|
||||
void die (int errcode, const char *fmt, ...);
|
||||
|
||||
/* exit status - bits below are ORed */
|
||||
#define EX_USAGE 1 /* incorrect invocation or permission */
|
||||
#define EX_SYSERR 2 /* out of memory, cannot fork, ... */
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
int all = 0;
|
||||
int verbose = 0;
|
||||
int priority = -1; /* non-prioritized swap by default */
|
||||
int mount_quiet = 0;
|
||||
|
||||
/* If true, don't complain if the device/file doesn't exist */
|
||||
int ifexists = 0;
|
||||
|
|
|
@ -400,8 +400,6 @@ usage (FILE *fp, int n)
|
|||
exit (n);
|
||||
}
|
||||
|
||||
int mount_quiet = 0;
|
||||
|
||||
/*
|
||||
* Look for an option in a comma-separated list
|
||||
*/
|
||||
|
|
|
@ -5,24 +5,6 @@
|
|||
#include "nls.h" /* _() */
|
||||
#include "sundries.h" /* EX_SYSERR */
|
||||
|
||||
void (*at_die)(void) = NULL;
|
||||
|
||||
/* Fatal error. Print message and exit. */
|
||||
void
|
||||
die(int err, const char *fmt, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
|
||||
if (at_die)
|
||||
(*at_die)();
|
||||
|
||||
exit(err);
|
||||
}
|
||||
|
||||
static void
|
||||
die_if_null(void *t) {
|
||||
if (t == NULL)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
#ifndef MOUNT_XMALLOC_H
|
||||
#define MOUNT_XMALLOC_H
|
||||
|
||||
extern void *xmalloc(size_t size);
|
||||
extern void *xrealloc(void *p, size_t size);
|
||||
extern char *xstrdup(const char *s);
|
||||
extern void die(int err, const char *fmt, ...);
|
||||
extern void (*at_die)(void);
|
||||
|
||||
#endif /* MOUNT_XMALLOC_H */
|
||||
|
|
Loading…
Reference in New Issue