libproc-ng & ps: fix warning reported by smatch
proc/ksym.c +279 read_file(54) info: redundant null check on buf calling free() proc/ksym.c +330 parse_ksyms(41) info: redundant null check on ksyms_data calling free() proc/ksym.c +332 parse_ksyms(43) info: redundant null check on ksyms_index calling free() proc/ksym.c +451 sysmap_mmap(110) info: redundant null check on sysmap_index calling free() proc/procps.h:74:5: warning: undefined preprocessor identifier 'SHARED' proc/slab.c +145 parse_slabinfo20(24) error: potential null derefence 'prev'. proc/slab.c +222 parse_slabinfo11(21) error: potential null derefence 'prev'. ps/stacktrace.c +131 debug(6) error: snprintf() is printing too much 99 vs 16 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
c1fa3bfce8
commit
9057b18a32
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
|
|
||||||
|
|
||||||
static void xdefault_error(const char *restrict fmts, ...) __attribute__((format(printf,1,2)));
|
static void xdefault_error(const char *restrict fmts, ...) __attribute__((format(printf,1,2)));
|
||||||
static void xdefault_error(const char *restrict fmts, ...) {
|
static void xdefault_error(const char *restrict fmts, ...) {
|
||||||
va_list va;
|
va_list va;
|
||||||
|
10
proc/ksym.c
10
proc/ksym.c
@ -275,7 +275,7 @@ open_again:
|
|||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
hell:
|
hell:
|
||||||
if(buf) free(buf);
|
free(buf);
|
||||||
*bufp = NULL;
|
*bufp = NULL;
|
||||||
*roomp = 0; /* this function will never work again */
|
*roomp = 0; /* this function will never work again */
|
||||||
total = 0;
|
total = 0;
|
||||||
@ -321,9 +321,11 @@ bad_parse:
|
|||||||
}
|
}
|
||||||
quiet_goodbye:
|
quiet_goodbye:
|
||||||
idx_room = 0;
|
idx_room = 0;
|
||||||
if(ksyms_data) free(ksyms_data) , ksyms_data = NULL;
|
free(ksyms_data);
|
||||||
|
ksyms_data = NULL;
|
||||||
ksyms_room = 0;
|
ksyms_room = 0;
|
||||||
if(ksyms_index) free(ksyms_index) , ksyms_index = NULL;
|
free(ksyms_index);
|
||||||
|
ksyms_index = NULL;
|
||||||
ksyms_count = 0;
|
ksyms_count = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -445,7 +447,7 @@ bad_open:
|
|||||||
|
|
||||||
sysmap_room=0;
|
sysmap_room=0;
|
||||||
sysmap_count=0;
|
sysmap_count=0;
|
||||||
if(sysmap_index) free(sysmap_index);
|
free(sysmap_index);
|
||||||
sysmap_index = NULL;
|
sysmap_index = NULL;
|
||||||
if(fd>=0) close(fd);
|
if(fd>=0) close(fd);
|
||||||
if(sysmap_data) munmap(sysmap_data, sbuf.st_size + 1);
|
if(sysmap_data) munmap(sysmap_data, sbuf.st_size + 1);
|
||||||
|
@ -71,8 +71,10 @@
|
|||||||
#define expected(x,y) (x)
|
#define expected(x,y) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SHARED==1 && (__GNUC__ > 2 || __GNUC_MINOR__ >= 96)
|
#ifdef SHARED
|
||||||
#define LABEL_OFFSET
|
# if SHARED==1 && (__GNUC__ > 2 || __GNUC_MINOR__ >= 96)
|
||||||
|
# define LABEL_OFFSET
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STRINGIFY_ARG(a) #a
|
#define STRINGIFY_ARG(a) #a
|
||||||
|
@ -141,7 +141,8 @@ static int parse_slabinfo20(struct slab_info **list, struct slab_stat *stats,
|
|||||||
if (entries++ == 0)
|
if (entries++ == 0)
|
||||||
*list = curr;
|
*list = curr;
|
||||||
else
|
else
|
||||||
prev->next = curr;
|
if (prev)
|
||||||
|
prev->next = curr;
|
||||||
|
|
||||||
assigned = sscanf(buffer, "%" STRINGIFY(SLAB_INFO_NAME_LEN)
|
assigned = sscanf(buffer, "%" STRINGIFY(SLAB_INFO_NAME_LEN)
|
||||||
"s %d %d %d %d %d : tunables %*d %*d %*d : \
|
"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)
|
if (entries++ == 0)
|
||||||
*list = curr;
|
*list = curr;
|
||||||
else
|
else
|
||||||
prev->next = curr;
|
if (prev)
|
||||||
|
prev->next = curr;
|
||||||
|
|
||||||
assigned = sscanf(buffer, "%" STRINGIFY(SLAB_INFO_NAME_LEN)
|
assigned = sscanf(buffer, "%" STRINGIFY(SLAB_INFO_NAME_LEN)
|
||||||
"s %d %d %d %d %d %d",
|
"s %d %d %d %d %d %d",
|
||||||
|
@ -128,7 +128,7 @@ void debug(int method, char *prog_name){
|
|||||||
char *args[4] = { "gdb", NULL, NULL, NULL };
|
char *args[4] = { "gdb", NULL, NULL, NULL };
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
snprintf (buf, 99, "%d", getpid ());
|
snprintf (buf, 16, "%d", getpid ());
|
||||||
|
|
||||||
args[1] = prog_name;
|
args[1] = prog_name;
|
||||||
args[2] = buf;
|
args[2] = buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user