On 06/28/2011 10:33 PM, Minoru Usui wrote:
> If virSysinfoParse{BIOS,System,Processor,Memory}()
> can't find newline('\n'), these return NULL.
> This patch fixes this.
>
> Signed-off-by: Minoru Usui <[email protected]>
> ---
> src/util/sysinfo.c | 23 +++++++++++++----------
> 1 files changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
> index d32f7f0..a6e525b 100644
> --- a/src/util/sysinfo.c
> +++ b/src/util/sysinfo.c
> @@ -131,7 +131,12 @@ static char *
> virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
> {
> char *cur, *eol = NULL;
> + char *tmp_base;
>
> + if ((tmp_base = strstr(base, "BIOS Information")) == NULL)
> + return base;
> +
> + base = tmp_base;
> if ((cur = strstr(base, "Vendor: ")) != NULL) {
I simplified this to use one less local variable.
ACK and push.
diff --git i/src/util/sysinfo.c w/src/util/sysinfo.c
index a6e525b..f4edde9 100644
--- i/src/util/sysinfo.c
+++ w/src/util/sysinfo.c
@@ -131,12 +131,11 @@ static char *
virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
{
char *cur, *eol = NULL;
- char *tmp_base;
- if ((tmp_base = strstr(base, "BIOS Information")) == NULL)
+ if ((cur = strstr(base, "BIOS Information")) == NULL)
return base;
- base = tmp_base;
+ base = cur;
if ((cur = strstr(base, "Vendor: ")) != NULL) {
cur += 8;
eol = strchr(cur, '\n');
@@ -172,12 +171,11 @@ static char *
virSysinfoParseSystem(char *base, virSysinfoDefPtr ret)
{
char *cur, *eol = NULL;
- char *tmp_base;
- if ((tmp_base = strstr(base, "System Information")) == NULL)
+ if ((cur = strstr(base, "System Information")) == NULL)
return base;
- base = tmp_base;
+ base = cur;
if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
cur += 14;
eol = strchr(cur, '\n');
--
Eric Blake [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
