* [PATCH] xen-detect: handle asprintf error
@ 2017-06-21 14:41 Wei Liu
2017-06-23 14:30 ` Andrew Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Wei Liu @ 2017-06-21 14:41 UTC (permalink / raw)
To: Xen-devel; +Cc: Juergen Gross, Ian Jackson, Olaf Hering, Wei Liu
Otherwise gcc with -Wunused will complain the return value is not
used.
Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Olaf Hering <olaf@aepfle.de>
Cc: Juergen Gross <jgross@suse.com>
---
tools/misc/xen-detect.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/tools/misc/xen-detect.c b/tools/misc/xen-detect.c
index a62747d316..fd187a4be6 100644
--- a/tools/misc/xen-detect.c
+++ b/tools/misc/xen-detect.c
@@ -90,8 +90,15 @@ static int check_for_xen(int pv_context)
found:
cpuid(base + 1, regs, pv_context);
if ( regs[0] )
- asprintf(&ver, "V%u.%u",
- (uint16_t)(regs[0] >> 16), (uint16_t)regs[0]);
+ {
+ int r = asprintf(&ver, "V%u.%u", (uint16_t)(regs[0] >> 16),
+ (uint16_t)regs[0]);
+ if ( r < 0 )
+ {
+ perror("asprintf failed\n");
+ exit(EXIT_FAILURE);
+ }
+ }
return regs[0];
}
@@ -193,8 +200,14 @@ static enum guest_type check_sysfs(void)
if ( tmp )
tmp[strlen(tmp) - 1] = 0;
if ( str && tmp )
- asprintf(&ver, "V%s.%s", str, tmp);
- else
+ {
+ int r = asprintf(&ver, "V%s.%s", str, tmp);
+ if ( r < 0 )
+ {
+ perror("asprintf failed\n");
+ exit(EXIT_FAILURE);
+ }
+ } else
ver = strdup("unknown version");
free(tmp);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xen-detect: handle asprintf error
2017-06-21 14:41 [PATCH] xen-detect: handle asprintf error Wei Liu
@ 2017-06-23 14:30 ` Andrew Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2017-06-23 14:30 UTC (permalink / raw)
To: Wei Liu, Xen-devel; +Cc: Juergen Gross, Olaf Hering, Ian Jackson
On 21/06/17 15:41, Wei Liu wrote:
> Otherwise gcc with -Wunused will complain the return value is not
> used.
>
> Reported-by: Olaf Hering <olaf@aepfle.de>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-23 14:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-21 14:41 [PATCH] xen-detect: handle asprintf error Wei Liu
2017-06-23 14:30 ` Andrew Cooper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).