diff --git a/proc/alloc.c b/proc/alloc.c index 0bc71a52..21185cc9 100644 --- a/proc/alloc.c +++ b/proc/alloc.c @@ -12,7 +12,6 @@ #include "alloc.h" - static void xdefault_error(const char *restrict fmts, ...) __attribute__((format(printf,1,2))); static void xdefault_error(const char *restrict fmts, ...) { va_list va; diff --git a/proc/ksym.c b/proc/ksym.c index ceddba13..b99a8a6c 100644 --- a/proc/ksym.c +++ b/proc/ksym.c @@ -275,7 +275,7 @@ open_again: close(fd); return; hell: - if(buf) free(buf); + free(buf); *bufp = NULL; *roomp = 0; /* this function will never work again */ total = 0; @@ -321,9 +321,11 @@ bad_parse: } quiet_goodbye: idx_room = 0; - if(ksyms_data) free(ksyms_data) , ksyms_data = NULL; + free(ksyms_data); + ksyms_data = NULL; ksyms_room = 0; - if(ksyms_index) free(ksyms_index) , ksyms_index = NULL; + free(ksyms_index); + ksyms_index = NULL; ksyms_count = 0; return 0; } @@ -445,7 +447,7 @@ bad_open: sysmap_room=0; sysmap_count=0; - if(sysmap_index) free(sysmap_index); + free(sysmap_index); sysmap_index = NULL; if(fd>=0) close(fd); if(sysmap_data) munmap(sysmap_data, sbuf.st_size + 1); diff --git a/proc/procps.h b/proc/procps.h index 4c6866e3..abbab98d 100644 --- a/proc/procps.h +++ b/proc/procps.h @@ -71,8 +71,10 @@ #define expected(x,y) (x) #endif -#if SHARED==1 && (__GNUC__ > 2 || __GNUC_MINOR__ >= 96) -#define LABEL_OFFSET +#ifdef SHARED +# if SHARED==1 && (__GNUC__ > 2 || __GNUC_MINOR__ >= 96) +# define LABEL_OFFSET +# endif #endif #define STRINGIFY_ARG(a) #a diff --git a/proc/slab.c b/proc/slab.c index ca41bf9e..66b0d4b5 100644 --- a/proc/slab.c +++ b/proc/slab.c @@ -141,7 +141,8 @@ static int parse_slabinfo20(struct slab_info **list, struct slab_stat *stats, if (entries++ == 0) *list = curr; else - prev->next = curr; + if (prev) + prev->next = curr; assigned = sscanf(buffer, "%" STRINGIFY(SLAB_INFO_NAME_LEN) "s %d %d %d %d %d : tunables %*d %*d %*d : \ @@ -218,7 +219,8 @@ static int parse_slabinfo11(struct slab_info **list, struct slab_stat *stats, if (entries++ == 0) *list = curr; else - prev->next = curr; + if (prev) + prev->next = curr; assigned = sscanf(buffer, "%" STRINGIFY(SLAB_INFO_NAME_LEN) "s %d %d %d %d %d %d", diff --git a/ps/stacktrace.c b/ps/stacktrace.c index c2b4ece0..60b89f44 100644 --- a/ps/stacktrace.c +++ b/ps/stacktrace.c @@ -128,7 +128,7 @@ void debug(int method, char *prog_name){ char *args[4] = { "gdb", NULL, NULL, NULL }; int x; - snprintf (buf, 99, "%d", getpid ()); + snprintf (buf, 16, "%d", getpid ()); args[1] = prog_name; args[2] = buf;