On 10/14/11 4:22 PM, "Eric Blake" <eblake@xxxxxxxxxx> wrote: > On 10/14/2011 04:25 PM, Roopa Prabhu wrote: >> From: Roopa Prabhu<roprabhu@xxxxxxxxx> >> >> Check strdup return value and fail if error >> >> Signed-off-by: Roopa Prabhu<roprabhu@xxxxxxxxx> >> --- >> src/util/pci.c | 8 +++++++- >> 1 files changed, 7 insertions(+), 1 deletions(-) >> >> >> diff --git a/src/util/pci.c b/src/util/pci.c >> index 2bbb90c..df4e6c8 100644 >> --- a/src/util/pci.c >> +++ b/src/util/pci.c >> @@ -2018,7 +2018,13 @@ pciDeviceNetName(char *device_link_sysfs_path, char >> **netname) >> >> /* Assume a single directory entry */ >> *netname = strdup(entry->d_name); >> - ret = 0; >> + if (!*netname) { >> + virReportOOMError(); >> + ret = -1; > > ret is already -1 > >> + } >> + else { > > style - "} else {" should always be on one line. But without the > redundant ret assignment, you don't need braces in the first place. > >> + ret = 0; >> + } > > ACK (only affects OOM corner case), and I'm pushing with this squashed in: > > diff --git i/src/util/pci.c w/src/util/pci.c > index df4e6c8..33b4b0e 100644 > --- i/src/util/pci.c > +++ w/src/util/pci.c > @@ -2018,13 +2018,10 @@ pciDeviceNetName(char *device_link_sysfs_path, > char **netname) > > /* Assume a single directory entry */ > *netname = strdup(entry->d_name); > - if (!*netname) { > + if (!*netname) > virReportOOMError(); > - ret = -1; > - } > - else { > + else > ret = 0; > - } > break; > } Ah..thanks. -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list