]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: use common libs
authorDavidlohr Bueso <dave@gnu.org>
Wed, 14 Sep 2011 18:07:06 +0000 (15:07 -0300)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Sep 2011 10:49:52 +0000 (12:49 +0200)
Get rid of the local xmalloc.[c/h] files by using the global xalloc and
strutils libraries.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
mount/Makefile.am
mount/fstab.c
mount/lomount.c
mount/mount.c
mount/sundries.c
mount/sundries.h
mount/umount.c
mount/xmalloc.c [deleted file]
mount/xmalloc.h [deleted file]

index 7aebfff666f2eb51fa03536c9e2f4701cdf66434..e9237b75af667a81c285792cee8c28afd2646a3d 100644 (file)
@@ -5,7 +5,7 @@ sbin_PROGRAMS = losetup swapon
 dist_man_MANS = fstab.5 mount.8 swapoff.8 swapon.8 umount.8 losetup.8
 
 # generic sources for all programs (mount, umount, losetup)
-srcs_common = sundries.c xmalloc.c $(top_srcdir)/lib/canonicalize.c sundries.h xmalloc.h
+srcs_common = sundries.c $(top_srcdir)/lib/canonicalize.c sundries.h
 
 # generic header for mount and umount
 hdrs_mount = fstab.h mount_mntent.h mount_constants.h \
index 77bf81cb952d92ccf8626bfb83014b326d69db88..6c0e89f3054be5a26942fe7e80ad3b4b10d09ffb 100644 (file)
 #include <sys/time.h>
 #include <time.h>
 #include <mntent.h>
+
 #include "mount_mntent.h"
 #include "fstab.h"
 #include "sundries.h"
-#include "xmalloc.h"
 #include "fsprobe.h"
 #include "pathnames.h"
 #include "nls.h"
index fad58d57f9753700b0e8561e3dfcd9e15db42e4e..74a874929afd3454ac96b604d73ecdb27c5d656e 100644 (file)
@@ -21,7 +21,6 @@
 #include "strutils.h"
 #include "nls.h"
 #include "sundries.h"
-#include "xmalloc.h"
 #include "pathnames.h"
 
 #ifdef LOOP_SET_FD
index e5e781f816673899ff49f68cd373534c6d59859f..d2ecb1de691788d94b6c68dc2abd4834f766148a 100644 (file)
@@ -32,7 +32,6 @@
 #include "devname.h"
 #include "mount_constants.h"
 #include "sundries.h"
-#include "xmalloc.h"
 #include "mount_mntent.h"
 #include "fstab.h"
 #include "lomount.h"
index 2dec37f451fbfcb63885987d33d54f4678ff8689..58f7b5de77cdb2e3ddb337271fac874a03334d6a 100644 (file)
@@ -15,7 +15,6 @@
 #include "canonicalize.h"
 
 #include "sundries.h"
-#include "xmalloc.h"
 #include "nls.h"
 
 int mount_quiet;
index 3b6a4644dba31354376a0bb2fae23b5ae226376e..5e3ddc3a90999b02932d01c0fbe7a070e8ed2037 100644 (file)
@@ -13,6 +13,9 @@
 #include <stdarg.h>
 #include <stdlib.h>
 
+#define XALLOC_EXIT_CODE 2 /* same as EX_SYSERR, for backwards compatibility */
+#include "xalloc.h"
+
 /* global mount, umount, and losetup variables */
 extern int mount_quiet;
 extern int verbose;
@@ -20,6 +23,7 @@ extern int nocanonicalize;
 extern char *progname;
 
 #define streq(s, t)    (strcmp ((s), (t)) == 0)
+#define my_free(_p)  free((void *) _p)
 
 void block_signals (int how);
 
@@ -30,8 +34,6 @@ void die(int err, const char *fmt, ...)
 
 int matching_type (const char *type, const char *types);
 int matching_opts (const char *options, const char *test_opts);
-void *xmalloc (size_t size);
-char *xstrdup (const char *s);
 char *xstrndup (const char *s, int n);
 char *xstrconcat3 (char *, const char *, const char *);
 char *xstrconcat4 (char *, const char *, const char *, const char *);
index 64f320c71b0f5ec1a4e6c6190bc186d22f23034b..5000aa5692b99e490b8db0fa553817f07881d677 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/mount.h>
+
 #include "mount_constants.h"
 #include "sundries.h"
 #include "getusername.h"
diff --git a/mount/xmalloc.c b/mount/xmalloc.c
deleted file mode 100644 (file)
index 3fd09fd..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>    /* strdup() */
-#include "xmalloc.h"
-#include "nls.h"       /* _() */
-#include "sundries.h"  /* EX_SYSERR */
-
-static void
-die_if_null(void *t) {
-       if (t == NULL)
-               die(EX_SYSERR, _("not enough memory"));
-}
-
-void *
-xmalloc (size_t size) {
-       void *t;
-
-       if (size == 0)
-               return NULL;
-
-       t = malloc(size);
-       die_if_null(t);
-
-       return t;
-}
-
-void *
-xrealloc (void *p, size_t size) {
-       void *t;
-
-       t = realloc(p, size);
-       die_if_null(t);
-
-       return t;
-}
-
-char *
-xstrdup (const char *s) {
-       char *t;
-
-       if (s == NULL)
-               return NULL;
-
-       t = strdup(s);
-       die_if_null(t);
-
-       return t;
-}
diff --git a/mount/xmalloc.h b/mount/xmalloc.h
deleted file mode 100644 (file)
index 2fc0a7e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#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);
-
-/*
- * free(p); when 'p' is 'const char *' makes gcc unhappy:
- *    warning: passing argument 1 of ‘free’ discards qualifiers from pointer target type
- */
-#define my_free(_p)    free((void *) _p)
-
-#endif  /* MOUNT_XMALLOC_H */