Magellan Linux

Contents of /trunk/elfutils/patches/elfutils-0.125-warn_unused_result.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (show annotations) (download)
Tue May 8 20:06:05 2007 UTC (17 years ago) by niro
File size: 7440 byte(s)
-import

1 #
2 #
3 # patch "libdwfl/ChangeLog"
4 # from [544a978ac9415cf07af04b56c8cd6d02cb2f08b8]
5 # to [547f91df0c66561c2a3b80ad13989a37ed6bfacf]
6 #
7 # patch "libdwfl/find-debuginfo.c"
8 # from [54d115ec2bad8682f03ae8c881a5af626c17b885]
9 # to [18a70eb75a8694cc379541c0a911d4740c2ec171]
10 #
11 # patch "libdwfl/linux-kernel-modules.c"
12 # from [56948fc9d0a7f74e1c87b0a2db789e6298b43120]
13 # to [17a0c60e241f083138511f715038799013766af5]
14 #
15 # patch "libdwfl/linux-proc-maps.c"
16 # from [fde12de5059ad5a304d3f6a58d47a8cdb093c220]
17 # to [dbf6bc63476a53167254dd01cd8d08e2990f8011]
18 #
19 ============================================================
20 --- libdwfl/ChangeLog 544a978ac9415cf07af04b56c8cd6d02cb2f08b8
21 +++ libdwfl/ChangeLog 547f91df0c66561c2a3b80ad13989a37ed6bfacf
22 @@ -1,5 +1,14 @@ 2007-01-10 Roland McGrath <roland@redh
23 2007-01-10 Roland McGrath <roland@redhat.com>
24
25 + * linux-kernel-modules.c (report_kernel): Check asprintf return value
26 + directly instead of via side effect, to silence warn_unused_result.
27 + (dwfl_linux_kernel_report_offline): Likewise.
28 + (dwfl_linux_kernel_find_elf): Likewise.
29 + (dwfl_linux_kernel_module_section_address): Likewise.
30 + * find-debuginfo.c (try_open): Likewise.
31 + * linux-proc-maps.c (find_sysinfo_ehdr): Likewise.
32 + (dwfl_linux_proc_report): Likewise.
33 +
34 * libdwfl.h (dwfl_begin): Require nonnull argument.
35
36 2006-12-27 Roland McGrath <roland@redhat.com>
37 ============================================================
38 --- libdwfl/find-debuginfo.c 54d115ec2bad8682f03ae8c881a5af626c17b885
39 +++ libdwfl/find-debuginfo.c 18a70eb75a8694cc379541c0a911d4740c2ec171
40 @@ -1,5 +1,5 @@
41 /* Standard find_debuginfo callback for libdwfl.
42 - Copyright (C) 2005, 2006 Red Hat, Inc.
43 + Copyright (C) 2005, 2006, 2007 Red Hat, Inc.
44 This file is part of Red Hat elfutils.
45
46 Red Hat elfutils is free software; you can redistribute it and/or modify
47 @@ -60,17 +60,16 @@ try_open (const char *dir, const char *s
48 try_open (const char *dir, const char *subdir, const char *debuglink,
49 char **debuginfo_file_name)
50 {
51 - char *fname = NULL;
52 + char *fname;
53 if (dir == NULL && subdir == NULL)
54 - fname = strdup (debuglink);
55 - else if (subdir == NULL)
56 - asprintf (&fname, "%s/%s", dir, debuglink);
57 - else if (dir == NULL)
58 - asprintf (&fname, "%s/%s", subdir, debuglink);
59 - else
60 - asprintf (&fname, "%s/%s/%s", dir, subdir, debuglink);
61 -
62 - if (fname == NULL)
63 + {
64 + fname = strdup (debuglink);
65 + if (fname == NULL)
66 + return -1;
67 + }
68 + else if ((subdir == NULL ? asprintf (&fname, "%s/%s", dir, debuglink)
69 + : dir == NULL ? asprintf (&fname, "%s/%s", subdir, debuglink)
70 + : asprintf (&fname, "%s/%s/%s", dir, subdir, debuglink)) < 0)
71 return -1;
72
73 int fd = TEMP_FAILURE_RETRY (open64 (fname, O_RDONLY));
74 ============================================================
75 --- libdwfl/linux-kernel-modules.c 56948fc9d0a7f74e1c87b0a2db789e6298b43120
76 +++ libdwfl/linux-kernel-modules.c 17a0c60e241f083138511f715038799013766af5
77 @@ -1,5 +1,5 @@
78 /* Standard libdwfl callbacks for debugging the running Linux kernel.
79 - Copyright (C) 2005, 2006 Red Hat, Inc.
80 + Copyright (C) 2005, 2006, 2007 Red Hat, Inc.
81 This file is part of Red Hat elfutils.
82
83 Red Hat elfutils is free software; you can redistribute it and/or modify
84 @@ -122,17 +122,17 @@ report_kernel (Dwfl *dwfl, const char *r
85 if (dwfl == NULL)
86 return -1;
87
88 - char *fname = NULL;
89 - if (release[0] == '/')
90 - asprintf (&fname, "%s/vmlinux", release);
91 - else
92 - asprintf (&fname, "/boot/vmlinux-%s", release);
93 + char *fname;
94 + if ((release[0] == '/'
95 + ? asprintf (&fname, "%s/vmlinux", release)
96 + : asprintf (&fname, "/boot/vmlinux-%s", release)) < 0)
97 + return -1;
98 int fd = try_kernel_name (dwfl, &fname);
99 if (fd < 0 && release[0] != '/')
100 {
101 free (fname);
102 - fname = NULL;
103 - asprintf (&fname, MODULEDIRFMT "/vmlinux", release);
104 + if (asprintf (&fname, MODULEDIRFMT "/vmlinux", release) < 0)
105 + return -1;
106 fd = try_kernel_name (dwfl, &fname);
107 }
108
109 @@ -195,8 +195,7 @@ dwfl_linux_kernel_report_offline (Dwfl *
110 modulesdir[0] = (char *) release;
111 else
112 {
113 - asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release);
114 - if (modulesdir[0] == NULL)
115 + if (asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release) < 0)
116 return errno;
117 }
118
119 @@ -310,8 +309,7 @@ dwfl_linux_kernel_find_elf (Dwfl_Module
120 /* Do "find /lib/modules/`uname -r`/kernel -name MODULE_NAME.ko". */
121
122 char *modulesdir[] = { NULL, NULL };
123 - asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release);
124 - if (modulesdir[0] == NULL)
125 + if (asprintf (&modulesdir[0], MODULEDIRFMT "/kernel", release) < 0)
126 return -1;
127
128 FTS *fts = fts_open (modulesdir, FTS_LOGICAL | FTS_NOSTAT, NULL);
129 @@ -417,9 +415,8 @@ dwfl_linux_kernel_module_section_address
130 const GElf_Shdr *shdr __attribute__ ((unused)),
131 Dwarf_Addr *addr)
132 {
133 - char *sysfile = NULL;
134 - asprintf (&sysfile, SECADDRDIRFMT "%s", modname, secname);
135 - if (sysfile == NULL)
136 + char *sysfile;
137 + if (asprintf (&sysfile, SECADDRDIRFMT "%s", modname, secname))
138 return ENOMEM;
139
140 FILE *f = fopen (sysfile, "r");
141 @@ -453,9 +450,8 @@ dwfl_linux_kernel_module_section_address
142 const bool is_init = !strncmp (secname, ".init", 5);
143 if (is_init)
144 {
145 - sysfile = NULL;
146 - asprintf (&sysfile, SECADDRDIRFMT "_%s", modname, &secname[1]);
147 - if (sysfile == NULL)
148 + if (asprintf (&sysfile, SECADDRDIRFMT "_%s",
149 + modname, &secname[1]) < 0)
150 return ENOMEM;
151 f = fopen (sysfile, "r");
152 free (sysfile);
153 @@ -469,10 +465,9 @@ dwfl_linux_kernel_module_section_address
154 size_t namelen = strlen (secname);
155 if (namelen >= MODULE_SECT_NAME_LEN)
156 {
157 - sysfile = NULL;
158 int len = asprintf (&sysfile, SECADDRDIRFMT "%s",
159 modname, secname);
160 - if (sysfile == NULL)
161 + if (len < 0)
162 return ENOMEM;
163 char *end = sysfile + len;
164 do
165 ============================================================
166 --- libdwfl/linux-proc-maps.c fde12de5059ad5a304d3f6a58d47a8cdb093c220
167 +++ libdwfl/linux-proc-maps.c dbf6bc63476a53167254dd01cd8d08e2990f8011
168 @@ -1,5 +1,5 @@
169 /* Standard libdwfl callbacks for debugging a live Linux process.
170 - Copyright (C) 2005 Red Hat, Inc.
171 + Copyright (C) 2005, 2007 Red Hat, Inc.
172 This file is part of Red Hat elfutils.
173
174 Red Hat elfutils is free software; you can redistribute it and/or modify
175 @@ -72,9 +72,8 @@ find_sysinfo_ehdr (pid_t pid, GElf_Addr
176 static int
177 find_sysinfo_ehdr (pid_t pid, GElf_Addr *sysinfo_ehdr)
178 {
179 - char *fname = NULL;
180 - asprintf (&fname, PROCAUXVFMT, pid);
181 - if (fname == NULL)
182 + char *fname;
183 + if (asprintf (&fname, PROCAUXVFMT, pid) < 0)
184 return ENOMEM;
185
186 int fd = open64 (fname, O_RDONLY);
187 @@ -243,9 +242,8 @@ dwfl_linux_proc_report (Dwfl *dwfl, pid_
188 if (result != 0)
189 return result;
190
191 - char *fname = NULL;
192 - asprintf (&fname, PROCMAPSFMT, pid);
193 - if (fname == NULL)
194 + char *fname;
195 + if (asprintf (&fname, PROCMAPSFMT, pid) < 0)
196 return ENOMEM;
197
198 FILE *f = fopen (fname, "r");
199 @@ -312,9 +310,8 @@ dwfl_linux_proc_find_elf (Dwfl_Module *m
200 {
201 /* Special case for in-memory ELF image. */
202
203 - char *fname = NULL;
204 - asprintf (&fname, PROCMEMFMT, pid);
205 - if (fname == NULL)
206 + char *fname;
207 + if (asprintf (&fname, PROCMEMFMT, pid) < 0)
208 return -1;
209
210 int fd = open64 (fname, O_RDONLY);