mirror of https://github.com/crash-utility/crash
Fixes to address several gcc-8.0.1 compiler warnings that are generated
when building with "make warn". The warnings are all false alarm messages of type [-Wformat-overflow=], [-Wformat-truncation=] and [-Wstringop-truncation]; the affected files are extensions.c, task.c, kernel.c, memory.c, remote.c, symbols.c, filesys.c and xen_hyper.c. (anderson@redhat.com)
This commit is contained in:
parent
dacfbe8ab1
commit
11eceac4ef
|
@ -1,8 +1,8 @@
|
|||
/* extensions.c - core analysis suite
|
||||
*
|
||||
* Copyright (C) 2001, 2002 Mission Critical Linux, Inc.
|
||||
* Copyright (C) 2002-2013 David Anderson
|
||||
* Copyright (C) 2002-2013 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2002-2013, 2018 David Anderson
|
||||
* Copyright (C) 2002-2013, 2018 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -363,7 +363,7 @@ preload_extensions(void)
|
|||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char dirbuf[BUFSIZE];
|
||||
char filename[BUFSIZE];
|
||||
char filename[BUFSIZE*2];
|
||||
int found;
|
||||
|
||||
if (!get_extensions_directory(dirbuf))
|
||||
|
|
16
filesys.c
16
filesys.c
|
@ -1366,10 +1366,10 @@ show_mounts(ulong one_vfsmount, int flags, struct task_context *namespace_contex
|
|||
long s_dirty;
|
||||
ulong devp, dirp, sbp, dirty, type, name;
|
||||
struct list_data list_data, *ld;
|
||||
char buf1[BUFSIZE];
|
||||
char buf1[BUFSIZE*2];
|
||||
char buf2[BUFSIZE];
|
||||
char buf3[BUFSIZE];
|
||||
char buf4[BUFSIZE];
|
||||
char buf4[BUFSIZE/2];
|
||||
ulong *dentry_list, *dp, *mntlist;
|
||||
ulong *vfsmnt;
|
||||
char *vfsmount_buf, *super_block_buf, *mount_buf;
|
||||
|
@ -1494,8 +1494,8 @@ show_mounts(ulong one_vfsmount, int flags, struct task_context *namespace_contex
|
|||
KVADDR, &name, sizeof(void *),
|
||||
"file_system_type name", FAULT_ON_ERROR);
|
||||
|
||||
if (read_string(name, buf1, BUFSIZE-1))
|
||||
sprintf(buf3, "%-6s ", buf1);
|
||||
if (read_string(name, buf4, BUFSIZE-1))
|
||||
sprintf(buf3, "%-6s ", buf4);
|
||||
else
|
||||
sprintf(buf3, "unknown ");
|
||||
|
||||
|
@ -2389,7 +2389,7 @@ open_files_dump(ulong task, int flags, struct reference *ref)
|
|||
char buf2[BUFSIZE];
|
||||
char buf3[BUFSIZE];
|
||||
char buf4[BUFSIZE];
|
||||
char root_pwd[BUFSIZE];
|
||||
char root_pwd[BUFSIZE*4];
|
||||
int root_pwd_printed = 0;
|
||||
int file_dump_flags = 0;
|
||||
|
||||
|
@ -3082,7 +3082,7 @@ get_pathname(ulong dentry, char *pathname, int length, int full, ulong vfsmnt)
|
|||
break;
|
||||
|
||||
if (tmp_dentry != dentry) {
|
||||
strncpy(tmpname, pathname, BUFSIZE);
|
||||
strncpy(tmpname, pathname, BUFSIZE-1);
|
||||
if (strlen(tmpname) + d_name_len < BUFSIZE) {
|
||||
if ((d_name_len > 1 || !STREQ(buf, "/")) &&
|
||||
!STRNEQ(tmpname, "/")) {
|
||||
|
@ -3613,8 +3613,8 @@ get_live_memory_source(void)
|
|||
{
|
||||
FILE *pipe;
|
||||
char buf[BUFSIZE];
|
||||
char modname1[BUFSIZE];
|
||||
char modname2[BUFSIZE];
|
||||
char modname1[BUFSIZE/2];
|
||||
char modname2[BUFSIZE/2];
|
||||
char *name;
|
||||
int use_module, crashbuiltin;
|
||||
struct stat stat1, stat2;
|
||||
|
|
36
kernel.c
36
kernel.c
|
@ -253,7 +253,9 @@ kernel_init()
|
|||
kt->utsname.domainname : "(not printable)");
|
||||
}
|
||||
|
||||
strncpy(buf, kt->utsname.release, MIN(strlen(kt->utsname.release), 65));
|
||||
strncpy(buf, kt->utsname.release, 65);
|
||||
if (buf[64])
|
||||
buf[64] = NULLCHAR;
|
||||
if (ascii_string(kt->utsname.release)) {
|
||||
char separator;
|
||||
|
||||
|
@ -1258,11 +1260,11 @@ verify_namelist()
|
|||
{
|
||||
int i;
|
||||
char command[BUFSIZE];
|
||||
char buffer[BUFSIZE];
|
||||
char buffer2[BUFSIZE];
|
||||
char buffer3[BUFSIZE];
|
||||
char buffer4[BUFSIZE];
|
||||
char buffer5[BUFSIZE];
|
||||
char buffer[BUFSIZE/2];
|
||||
char buffer2[BUFSIZE/2];
|
||||
char buffer3[BUFSIZE/2];
|
||||
char buffer4[BUFSIZE/2];
|
||||
char buffer5[BUFSIZE*2];
|
||||
char *p1;
|
||||
FILE *pipe;
|
||||
int found;
|
||||
|
@ -1379,12 +1381,12 @@ verify_namelist()
|
|||
else
|
||||
sprintf(buffer, "%s", ACTIVE() ? "live system" : pc->dumpfile);
|
||||
|
||||
sprintf(buffer2, " %s is %s -- %s is %s\n",
|
||||
sprintf(buffer5, " %s is %s -- %s is %s\n",
|
||||
namelist, namelist_smp ? "SMP" : "not SMP",
|
||||
buffer, target_smp ? "SMP" : "not SMP");
|
||||
|
||||
error(INFO, "incompatible arguments: %s%s",
|
||||
strlen(buffer2) > 48 ? "\n " : "", buffer2);
|
||||
strlen(buffer5) > 48 ? "\n " : "", buffer5);
|
||||
|
||||
program_usage(SHORT_FORM);
|
||||
}
|
||||
|
@ -1396,7 +1398,7 @@ static void
|
|||
source_tree_init(void)
|
||||
{
|
||||
FILE *pipe;
|
||||
char command[BUFSIZE];
|
||||
char command[BUFSIZE*2];
|
||||
char buf[BUFSIZE];
|
||||
|
||||
if (!is_directory(kt->source_tree)) {
|
||||
|
@ -1429,7 +1431,7 @@ list_source_code(struct gnu_request *req, int count_entered)
|
|||
int argc, line, last, done, assembly;
|
||||
char buf1[BUFSIZE];
|
||||
char buf2[BUFSIZE];
|
||||
char buf3[BUFSIZE];
|
||||
char buf3[BUFSIZE*2];
|
||||
char file[BUFSIZE];
|
||||
char *argv[MAXARGS];
|
||||
struct syment *sp;
|
||||
|
@ -2555,7 +2557,7 @@ cmd_bt(void)
|
|||
} else {
|
||||
bt->flags |= BT_CPUMASK;
|
||||
BZERO(arg_buf, BUFSIZE);
|
||||
strncpy(arg_buf, optarg, strlen(optarg));
|
||||
strcpy(arg_buf, optarg);
|
||||
cpus = get_cpumask_buf();
|
||||
}
|
||||
break;
|
||||
|
@ -4748,7 +4750,7 @@ find_module_objfile(char *modref, char *filename, char *tree)
|
|||
retbuf = module_objfile_search(modref, filename, tree);
|
||||
|
||||
if (!retbuf) {
|
||||
strncpy(tmpref, modref, BUFSIZE);
|
||||
strncpy(tmpref, modref, BUFSIZE-1);
|
||||
for (c = 0; c < BUFSIZE && tmpref[c]; c++)
|
||||
if (tmpref[c] == '_')
|
||||
tmpref[c] = '-';
|
||||
|
@ -6244,7 +6246,7 @@ cmd_irq(void)
|
|||
} else {
|
||||
choose_cpu = 1;
|
||||
BZERO(arg_buf, BUFSIZE);
|
||||
strncpy(arg_buf, optarg, strlen(optarg));
|
||||
strcpy(arg_buf, optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -6988,8 +6990,8 @@ generic_get_irq_affinity(int irq)
|
|||
BZERO(buf, BUFSIZE);
|
||||
if (read_string(name, buf, BUFSIZE-1)) {
|
||||
if (strlen(name_buf) != 0)
|
||||
strncat(name_buf, ",", 2);
|
||||
strncat(name_buf, buf, strlen(buf));
|
||||
strcat(name_buf, ",");
|
||||
strcat(name_buf, buf);
|
||||
}
|
||||
|
||||
readmem(action+OFFSET(irqaction_next), KVADDR,
|
||||
|
@ -7128,8 +7130,8 @@ generic_show_interrupts(int irq, ulong *cpus)
|
|||
BZERO(buf2, BUFSIZE);
|
||||
if (read_string(name, buf2, BUFSIZE-1)) {
|
||||
if (strlen(name_buf) != 0)
|
||||
strncat(name_buf, ",", 2);
|
||||
strncat(name_buf, buf2, strlen(buf2));
|
||||
strcat(name_buf, ",");
|
||||
strcat(name_buf, buf2);
|
||||
}
|
||||
|
||||
readmem(action+OFFSET(irqaction_next), KVADDR,
|
||||
|
|
6
memory.c
6
memory.c
|
@ -1438,7 +1438,7 @@ display_memory(ulonglong addr, long count, ulong flag, int memtype, void *opt)
|
|||
char ch;
|
||||
int linelen;
|
||||
char buf[BUFSIZE];
|
||||
char slab[BUFSIZE];
|
||||
char slab[BUFSIZE/2];
|
||||
int ascii_start;
|
||||
ulong error_handle;
|
||||
char *hex_64_fmt = BITS32() ? "%.*llx " : "%.*lx ";
|
||||
|
@ -1952,7 +1952,7 @@ char *
|
|||
format_stack_entry(struct bt_info *bt, char *retbuf, ulong value, ulong limit)
|
||||
{
|
||||
char buf[BUFSIZE];
|
||||
char slab[BUFSIZE];
|
||||
char slab[BUFSIZE/2];
|
||||
|
||||
if (BITS32()) {
|
||||
if ((bt->flags & BT_FULL_SYM_SLAB) && accessible(value)) {
|
||||
|
@ -4014,7 +4014,7 @@ vm_area_page_dump(ulong vma,
|
|||
int display;
|
||||
char buf1[BUFSIZE];
|
||||
char buf2[BUFSIZE];
|
||||
char buf3[BUFSIZE];
|
||||
char buf3[BUFSIZE*2];
|
||||
char buf4[BUFSIZE];
|
||||
|
||||
if (mm == symbol_value("init_mm"))
|
||||
|
|
16
remote.c
16
remote.c
|
@ -1,8 +1,8 @@
|
|||
/* remote.c - core analysis suite
|
||||
*
|
||||
* Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
|
||||
* Copyright (C) 2002, 2003, 2004, 2005, 2009, 2011 David Anderson
|
||||
* Copyright (C) 2002, 2003, 2004, 2005, 2009, 2011 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2002, 2003, 2004, 2005, 2009, 2011, 2018 David Anderson
|
||||
* Copyright (C) 2002, 2003, 2004, 2005, 2009, 2011, 2018 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -2759,7 +2759,7 @@ identical_namelist(char *file, struct remote_file *rfp)
|
|||
long csum;
|
||||
char sendbuf[BUFSIZE];
|
||||
char recvbuf[BUFSIZE];
|
||||
char readbuf[BUFSIZE];
|
||||
char readbuf[BUFSIZE*2];
|
||||
|
||||
if (stat(file, &sbuf) < 0)
|
||||
return FALSE;
|
||||
|
@ -3264,7 +3264,7 @@ static int
|
|||
copy_remote_file(struct remote_file *rfp, int fd, char *file, char *ttystr)
|
||||
{
|
||||
char sendbuf[BUFSIZE];
|
||||
char recvbuf[BUFSIZE];
|
||||
char recvbuf[BUFSIZE*2];
|
||||
char readbuf[READBUFSIZE];
|
||||
char *bufptr;
|
||||
long pct, last;
|
||||
|
@ -3399,7 +3399,7 @@ copy_remote_gzip_file(struct remote_file *rfp, char *file, char *ttystr)
|
|||
}
|
||||
if (STRNEQ(bufptr, DONEMSG) ||
|
||||
STRNEQ(bufptr, DATAMSG)) {
|
||||
strncpy(gziphdr, bufptr, DATA_HDRSIZE);
|
||||
BCOPY(bufptr, gziphdr, DATA_HDRSIZE);
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp,
|
||||
"copy_remote_gzip_file: [%s]\n",
|
||||
|
@ -3647,7 +3647,7 @@ remote_memory_dump(int verbose)
|
|||
}
|
||||
if (STRNEQ(bufptr, DONEMSG) ||
|
||||
STRNEQ(bufptr, DATAMSG)) {
|
||||
strncpy(datahdr, bufptr, DATA_HDRSIZE);
|
||||
BCOPY(bufptr, datahdr, DATA_HDRSIZE);
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp,
|
||||
"remote_memory_dump: [%s]\n",
|
||||
|
@ -3788,7 +3788,7 @@ int
|
|||
remote_execute(void)
|
||||
{
|
||||
char command[BUFSIZE];
|
||||
char sendbuf[BUFSIZE];
|
||||
char sendbuf[BUFSIZE*2];
|
||||
char readbuf[READBUFSIZE];
|
||||
char datahdr[DATA_HDRSIZE];
|
||||
char *bufptr, *p1;
|
||||
|
@ -3833,7 +3833,7 @@ remote_execute(void)
|
|||
}
|
||||
if (STRNEQ(bufptr, DONEMSG) ||
|
||||
STRNEQ(bufptr, DATAMSG)) {
|
||||
strncpy(datahdr, bufptr, DATA_HDRSIZE);
|
||||
BCOPY(bufptr, datahdr, DATA_HDRSIZE);
|
||||
if (CRASHDEBUG(1))
|
||||
fprintf(fp,
|
||||
"remote_execute: [%s]\n",
|
||||
|
|
14
symbols.c
14
symbols.c
|
@ -1364,9 +1364,9 @@ store_module_symbols_v1(ulong total, int mods_installed)
|
|||
struct module_symbol *modsym;
|
||||
struct load_module *lm;
|
||||
char buf1[BUFSIZE];
|
||||
char buf2[BUFSIZE];
|
||||
char buf2[BUFSIZE*2];
|
||||
char name[BUFSIZE];
|
||||
char rodata[BUFSIZE];
|
||||
char rodata[BUFSIZE*2];
|
||||
char *strbuf, *modbuf, *modsymbuf;
|
||||
struct syment *sp;
|
||||
ulong first, last;
|
||||
|
@ -1432,7 +1432,7 @@ store_module_symbols_v1(ulong total, int mods_installed)
|
|||
error(INFO,
|
||||
"module name greater than MAX_MOD_NAME: %s\n",
|
||||
name);
|
||||
strncpy(lm->mod_name, name, MAX_MOD_NAME-1);
|
||||
BCOPY(name, lm->mod_name, MAX_MOD_NAME-1);
|
||||
}
|
||||
|
||||
lm->mod_flags = MOD_EXT_SYMS;
|
||||
|
@ -5932,7 +5932,7 @@ static int
|
|||
dereference_pointer(ulong addr, struct datatype_member *dm, ulong flags)
|
||||
{
|
||||
char buf1[BUFSIZE];
|
||||
char buf2[BUFSIZE];
|
||||
char buf2[BUFSIZE*2];
|
||||
char *typeptr, *member, *charptr, *voidptr, *p1, *sym;
|
||||
int found, ptrptr, funcptr, typedef_is_ptr, use_symbol;
|
||||
ulong target, value;
|
||||
|
@ -11419,7 +11419,7 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
|
|||
ulong vaddr, array_entry, attribute, owner, name, address;
|
||||
long name_type;
|
||||
char buf[BUFSIZE];
|
||||
char section_name[BUFSIZE];
|
||||
char section_name[BUFSIZE/2];
|
||||
ulong section_vaddr;
|
||||
|
||||
#if defined(GDB_5_3) || defined(GDB_6_0) || defined(GDB_6_1)
|
||||
|
@ -11578,7 +11578,7 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
|
|||
}
|
||||
}
|
||||
|
||||
BZERO(section_name, BUFSIZE);
|
||||
BZERO(section_name, BUFSIZE/2);
|
||||
if (!read_string(name, section_name, 32)) {
|
||||
done = TRUE;
|
||||
retval = FALSE;
|
||||
|
@ -11606,7 +11606,7 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req)
|
|||
buflen *= 2;
|
||||
}
|
||||
shift_string_right(req->buf, strlen(buf));
|
||||
strncpy(req->buf, buf, strlen(buf));
|
||||
BCOPY(buf, req->buf, strlen(buf));
|
||||
retval = TRUE;
|
||||
} else {
|
||||
sprintf(buf, " -s %s 0x%lx", section_name, section_vaddr);
|
||||
|
|
2
task.c
2
task.c
|
@ -8325,7 +8325,7 @@ cmd_runq(void)
|
|||
} else {
|
||||
pc->curcmd_flags |= CPUMASK;
|
||||
BZERO(arg_buf, BUFSIZE);
|
||||
strncpy(arg_buf, optarg, strlen(optarg));
|
||||
strcpy(arg_buf, optarg);
|
||||
cpus = get_cpumask_buf();
|
||||
make_cpumask(arg_buf, cpus, FAULT_ON_ERROR, NULL);
|
||||
pc->curcmd_private = (ulong)cpus;
|
||||
|
|
|
@ -534,7 +534,7 @@ xen_hyper_schedule_init(void)
|
|||
error(FATAL, "cannot malloc scheduler_name space.\n");
|
||||
}
|
||||
BZERO(xhscht->name, strlen(buf) + 1);
|
||||
strncpy(xhscht->name, buf, strlen(buf));
|
||||
BCOPY(buf, xhscht->name, strlen(buf));
|
||||
break;
|
||||
}
|
||||
addr += sizeof(long) * nr_schedulers;
|
||||
|
|
Loading…
Reference in New Issue