# # # patch "libdwfl/ChangeLog" # from [544a978ac9415cf07af04b56c8cd6d02cb2f08b8] # to [547f91df0c66561c2a3b80ad13989a37ed6bfacf] # # patch "libdwfl/find-debuginfo.c" # from [54d115ec2bad8682f03ae8c881a5af626c17b885] # to [18a70eb75a8694cc379541c0a911d4740c2ec171] # # patch "libdwfl/linux-kernel-modules.c" # from [56948fc9d0a7f74e1c87b0a2db789e6298b43120] # to [17a0c60e241f083138511f715038799013766af5] # # patch "libdwfl/linux-proc-maps.c" # from [fde12de5059ad5a304d3f6a58d47a8cdb093c220] # to [dbf6bc63476a53167254dd01cd8d08e2990f8011] # ============================================================ --- libdwfl/ChangeLog 544a978ac9415cf07af04b56c8cd6d02cb2f08b8 +++ libdwfl/ChangeLog 547f91df0c66561c2a3b80ad13989a37ed6bfacf @@ -1,5 +1,14 @@ 2007-01-10 Roland McGrath + * linux-kernel-modules.c (report_kernel): Check asprintf return value + directly instead of via side effect, to silence warn_unused_result. + (dwfl_linux_kernel_report_offline): Likewise. + (dwfl_linux_kernel_find_elf): Likewise. + (dwfl_linux_kernel_module_section_address): Likewise. + * find-debuginfo.c (try_open): Likewise. + * linux-proc-maps.c (find_sysinfo_ehdr): Likewise. + (dwfl_linux_proc_report): Likewise. + * libdwfl.h (dwfl_begin): Require nonnull argument. 2006-12-27 Roland McGrath ============================================================ --- libdwfl/find-debuginfo.c 54d115ec2bad8682f03ae8c881a5af626c17b885 +++ libdwfl/find-debuginfo.c 18a70eb75a8694cc379541c0a911d4740c2ec171 @@ -1,5 +1,5 @@ /* Standard find_debuginfo callback for libdwfl. - Copyright (C) 2005, 2006 Red Hat, Inc. + Copyright (C) 2005, 2006, 2007 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -60,17 +60,16 @@ try_open (const char *dir, const char *s try_open (const char *dir, const char *subdir, const char *debuglink, char **debuginfo_file_name) { - char *fname = NULL; + char *fname; if (dir == NULL && subdir == NULL) - fname = strdup (debuglink); - else if (subdir == NULL) - asprintf (&fname, "%s/%s", dir, debuglink); - else if (dir == NULL) - asprintf (&fname, "%s/%s", subdir, debuglink); - else - asprintf (&fname, "%s/%s/%s", dir, subdir, debuglink); - - if (fname == NULL) + { + fname = strdup (debuglink); + if (fname == NULL) + return -1; + } + else if ((subdir == NULL ? asprintf (&fname, "%s/%s", dir, debuglink) + : dir == NULL ? asprintf (&fname, "%s/%s", subdir, debuglink) + : asprintf (&fname, "%s/%s/%s", dir, subdir, debuglink)) < 0) return -1; int fd = TEMP_FAILURE_RETRY (open64 (fname, O_RDONLY)); ============================================================ --- libdwfl/linux-kernel-modules.c 56948fc9d0a7f74e1c87b0a2db789e6298b43120 +++ libdwfl/linux-kernel-modules.c 17a0c60e241f083138511f715038799013766af5 @@ -1,5 +1,5 @@ /* Standard libdwfl callbacks for debugging the running Linux kernel. - Copyright (C) 2005, 2006 Red Hat, Inc. + Copyright (C) 2005, 2006, 2007 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -122,17 +122,17 @@ report_kernel (Dwfl *dwfl, const char *r if (dwfl == NULL) return -1; - char *fname = NULL; - if (release[0] == '/') - asprintf (&fname, "%s/vmlinux", release); - else - asprintf (&fname, "/boot/vmlinux-%s", release); + char *fname; + if ((release[0] == '/' + ? asprintf (&fname, "%s/vmlinux", release) + : asprintf (&fname, "/boot/vmlinux-%s", release)) < 0) + return -1; int fd = try_kernel_name (dwfl, &fname); if (fd < 0 && release[0] != '/') { free (fname); - fname = NULL; - asprintf (&fname, MODULEDIRFMT "/vmlinux", release); + if (asprintf (&fname, MODULEDIRFMT "/vmlinux", release) < 0) + return -1; fd = try_kernel_name (dwfl, &fname); } @@ -195,8 +195,7 @@ dwfl_linux_kernel_report_offline (Dwfl * modulesdir[0] = (char *) release; else { - asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release); - if (modulesdir[0] == NULL) + if (asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release) < 0) return errno; } @@ -310,8 +309,7 @@ dwfl_linux_kernel_find_elf (Dwfl_Module /* Do "find /lib/modules/`uname -r`/kernel -name MODULE_NAME.ko". */ char *modulesdir[] = { NULL, NULL }; - asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release); - if (modulesdir[0] == NULL) + if (asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release) < 0) return -1; FTS *fts = fts_open (modulesdir, FTS_LOGICAL | FTS_NOSTAT, NULL); @@ -417,9 +415,8 @@ dwfl_linux_kernel_module_section_address const GElf_Shdr *shdr __attribute__ ((unused)), Dwarf_Addr *addr) { - char *sysfile = NULL; - asprintf (&sysfile, SECADDRDIRFMT "%s", modname, secname); - if (sysfile == NULL) + char *sysfile; + if (asprintf (&sysfile, SECADDRDIRFMT "%s", modname, secname)) return ENOMEM; FILE *f = fopen (sysfile, "r"); @@ -453,9 +450,8 @@ dwfl_linux_kernel_module_section_address const bool is_init = !strncmp (secname, ".init", 5); if (is_init) { - sysfile = NULL; - asprintf (&sysfile, SECADDRDIRFMT "_%s", modname, &secname[1]); - if (sysfile == NULL) + if (asprintf (&sysfile, SECADDRDIRFMT "_%s", + modname, &secname[1]) < 0) return ENOMEM; f = fopen (sysfile, "r"); free (sysfile); @@ -469,10 +465,9 @@ dwfl_linux_kernel_module_section_address size_t namelen = strlen (secname); if (namelen >= MODULE_SECT_NAME_LEN) { - sysfile = NULL; int len = asprintf (&sysfile, SECADDRDIRFMT "%s", modname, secname); - if (sysfile == NULL) + if (len < 0) return ENOMEM; char *end = sysfile + len; do ============================================================ --- libdwfl/linux-proc-maps.c fde12de5059ad5a304d3f6a58d47a8cdb093c220 +++ libdwfl/linux-proc-maps.c dbf6bc63476a53167254dd01cd8d08e2990f8011 @@ -1,5 +1,5 @@ /* Standard libdwfl callbacks for debugging a live Linux process. - Copyright (C) 2005 Red Hat, Inc. + Copyright (C) 2005, 2007 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -72,9 +72,8 @@ find_sysinfo_ehdr (pid_t pid, GElf_Addr static int find_sysinfo_ehdr (pid_t pid, GElf_Addr *sysinfo_ehdr) { - char *fname = NULL; - asprintf (&fname, PROCAUXVFMT, pid); - if (fname == NULL) + char *fname; + if (asprintf (&fname, PROCAUXVFMT, pid) < 0) return ENOMEM; int fd = open64 (fname, O_RDONLY); @@ -243,9 +242,8 @@ dwfl_linux_proc_report (Dwfl *dwfl, pid_ if (result != 0) return result; - char *fname = NULL; - asprintf (&fname, PROCMAPSFMT, pid); - if (fname == NULL) + char *fname; + if (asprintf (&fname, PROCMAPSFMT, pid) < 0) return ENOMEM; FILE *f = fopen (fname, "r"); @@ -312,9 +310,8 @@ dwfl_linux_proc_find_elf (Dwfl_Module *m { /* Special case for in-memory ELF image. */ - char *fname = NULL; - asprintf (&fname, PROCMEMFMT, pid); - if (fname == NULL) + char *fname; + if (asprintf (&fname, PROCMEMFMT, pid) < 0) return -1; int fd = open64 (fname, O_RDONLY);