[sheepdog-users] [PATCH stable-0.8 18/22] lib: fix compiler error in logger.c
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Mon Feb 24 08:07:06 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>
---
lib/logger.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/logger.c b/lib/logger.c
index 8be2bfd..af7b32a 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -741,9 +741,11 @@ static bool check_gdb(void)
return system("which gdb > /dev/null") == 0;
}
+#define SD_ARG_MAX (sysconf(_SC_ARG_MAX))
+
static int gdb_cmd(const char *cmd)
{
- char time_str[256], cmd_str[ARG_MAX];
+ char time_str[256], cmd_str[SD_ARG_MAX];
time_t ti;
struct tm tm;
@@ -794,7 +796,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], info[256], **str;
+ char cmd[SD_ARG_MAX], info[256], **str;
FILE *f;
/*
--
1.7.10.4
More information about the sheepdog-users
mailing list