Skip to contentSkip to conversation

c.h: move up declaration of program_invocation_short_name before usage

PATCH Applied maximilian attems 2 participants 6 messages Jul 31, 2011 – Aug 2, 2011 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 c.h: move up declaration of program_invocation_short_name before usage

fixes:
../include/c.h: In function ‘errmsg’:
../include/c.h:111:26: error: ‘program_invocation_short_name’ undeclared (first use in this function)
../include/c.h:111:26: note: each undeclared identifier is reported only once for each function it appears in

---
 include/c.h |   70 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 35 insertions(+), 35 deletions(-)
include/c.h +35 -35
index 70f403c..79581ae 100644
@@ -103,6 +103,41 @@
 	_max1 > _max2 ? _max1 : _max2; })
 #endif
 
+#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
+# ifdef HAVE___PROGNAME
+extern char *__progname;
+#  define program_invocation_short_name __progname
+# else
+#  ifdef HAVE_GETEXECNAME
+#   include <stdlib.h>
+#   define program_invocation_short_name \
+		prog_inv_sh_nm_from_file(getexecname(), 0)
+#  else
+#   define program_invocation_short_name \
+		prog_inv_sh_nm_from_file(__FILE__, 1)
+#  endif
+static char prog_inv_sh_nm_buf[256];
+static inline char *
+prog_inv_sh_nm_from_file(char *f, char stripext)
+{
+	char *t;
+
+	if ((t = strrchr(f, '/')) != NULL)
+		t++;
+	else
+		t = f;
+
+	strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
+	prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
+
+	if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
+		*t = '\0';
+
+	return prog_inv_sh_nm_buf;
+}
+# endif
+#endif
+
 
 #ifndef HAVE_ERR_H
 static inline void
@@ -160,41 +195,6 @@ static inline int dirfd(DIR *d)
 }
 #endif
 
-#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
-# ifdef HAVE___PROGNAME
-extern char *__progname;
-#  define program_invocation_short_name __progname
-# else
-#  ifdef HAVE_GETEXECNAME
-#   include <stdlib.h>
-#   define program_invocation_short_name \
-		prog_inv_sh_nm_from_file(getexecname(), 0)
-#  else
-#   define program_invocation_short_name \
-		prog_inv_sh_nm_from_file(__FILE__, 1)
-#  endif
-static char prog_inv_sh_nm_buf[256];
-static inline char *
-prog_inv_sh_nm_from_file(char *f, char stripext)
-{
-	char *t;
-
-	if ((t = strrchr(f, '/')) != NULL)
-		t++;
-	else
-		t = f;
-
-	strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
-	prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
-
-	if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
-		*t = '\0';
-
-	return prog_inv_sh_nm_buf;
-}
-# endif
-#endif
-
 /*
  * Fallback defines for old versions of glibc
  */
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 2/3 c.h: Include stdlib.h unconditionaly

No point in hiding it down in an ifdef maze,
as it may get used by exit(3).

---
 include/c.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/c.h +1 -1
index 79581ae..a9cd1f3 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 
@@ -109,7 +110,6 @@ extern char *__progname;
 #  define program_invocation_short_name __progname
 # else
 #  ifdef HAVE_GETEXECNAME
-#   include <stdlib.h>
 #   define program_invocation_short_name \
 		prog_inv_sh_nm_from_file(getexecname(), 0)
 #  else
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/3 mkswap: Use c.h

In reply to maximilian attems

Fixes mkswap compilation against klibc.

---
 disk-utils/mkswap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
disk-utils/mkswap.c +1 -1
index a621641..ab16d13 100644
@@ -41,7 +41,6 @@
 #include <sys/utsname.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <err.h>
 #include <getopt.h>
 #ifdef HAVE_LIBSELINUX
 #include <selinux/selinux.h>
@@ -57,6 +56,7 @@
 #include "wholedisk.h"
 #include "writeall.h"
 #include "xalloc.h"
+#include "c.h"
 
 #ifdef HAVE_LIBUUID
 # include <uuid.h>
Signature · 1 line
1.7.5.4
maintainer Applied
#5 lore raw
In reply to maximilian attems
Quoted 2 lines · maximilian attems
 include/c.h |   70 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 35 insertions(+), 35 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer Applied
#2 lore raw

Re: [PATCH 2/3] c.h: Include stdlib.h unconditionaly

In reply to maximilian attems
Quoted 2 lines · maximilian attems
 include/c.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer Applied
#4 lore raw

Re: [PATCH 3/3] mkswap: Use c.h

In reply to maximilian attems
Quoted 2 lines · maximilian attems
 disk-utils/mkswap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com