[sheepdog] [PATCH stable-0.7] lib: fix compiler error in logger.c

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Tue Mar 11 02:41:08 CET 2014


From: Robin Dong <sanbai at taobao.com>

When build sheepdog in centos6, it will report:

    logger.c: In function ‘gdb_cmd’:
    logger.c:746: error: ‘ARG_MAX’ undeclared (first use in this function)
    logger.c:746: error: (Each undeclared identifier is reported only once
    logger.c:746: error: for each function it appears in.)
    logger.c:746: warning: unused variable ‘cmd_str’
    logger.c: In function ‘sd_backtrace’:
    logger.c:797: error: ‘ARG_MAX’ undeclared (first use in this function)
    logger.c:797: warning: unused variable ‘cmd’

the reason has been explained here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518858
and the standard revolution is using 'sysconf()'.

Signed-off-by: Robin Dong <sanbai at taobao.com>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>

Conflicts:
	lib/logger.c

Conflicts were resolved by Hitoshi Mitake.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 lib/logger.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index f5111ab..d313588 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -747,6 +747,8 @@ static bool check_gdb(void)
 	return system("which gdb > /dev/null") == 0;
 }
 
+#define SD_ARG_MAX (sysconf(_SC_ARG_MAX))
+
 /*
  * __builtin_frame_address() returns address in frame pointer register if any
  * (e.g, in x86 it returns EBP). If no dedicated register, the frame address is
@@ -765,7 +767,7 @@ static bool check_gdb(void)
 __attribute__ ((__noinline__))
 int __sd_dump_variable(const char *var)
 {
-	char cmd[ARG_MAX], path[PATH_MAX], info[256];
+	char cmd[SD_ARG_MAX], path[PATH_MAX], info[256];
 	FILE *f = NULL;
 	void *base_sp = FRAME_POINTER;
 
@@ -824,7 +826,7 @@ static int dump_stack_frames(void)
 		return -1;
 
 	for (i = 1; i < SD_MAX_STACK_DEPTH; i++) {
-		char cmd[ARG_MAX], info[256];
+		char cmd[SD_ARG_MAX], info[256];
 		FILE *f = NULL;
 		bool found = false;
 
@@ -883,7 +885,7 @@ void sd_backtrace(void)
 
 	for (i = 1; i < n; i++) { /* addrs[0] is here, so skip it */
 		void *addr = addrs[i];
-		char cmd[ARG_MAX], path[PATH_MAX], info[256], **str;
+		char cmd[SD_ARG_MAX], path[PATH_MAX], info[256], **str;
 		FILE *f;
 
 		/*
-- 
1.7.10.4




More information about the sheepdog mailing list