Re: [PATCH] If no devices were found do not SIGSEGV (#567939)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 03/05/2010 10:33 AM, Martin Sivak wrote:
---
  loader/driverdisk.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/loader/driverdisk.c b/loader/driverdisk.c
index bb6ed22..192beb0 100644
--- a/loader/driverdisk.c
+++ b/loader/driverdisk.c
@@ -361,7 +361,7 @@ int getRemovableDevices(char *** devNames) {

      devs = getDevices(DEVICE_DISK | DEVICE_CDROM);

-    for (i = 0; devs[i] ; i++) {
+    if(devs) for (i = 0; devs[i] ; i++) {
          if (devs[i]->priv.removable) {
              *devNames = realloc(*devNames, (numDevices + 2) * sizeof(char *));
              (*devNames)[numDevices] = strdup(devs[i]->device);

Sorry but having an if and a for on the same line is just too ugly,
how about this instead:
+    for (i = 0; devs && devs[i] ; i++) {

@@ -369,9 +369,11 @@ int getRemovableDevices(char *** devNames) {
              numDevices ++;
          }
      }
+
      if (!numDevices) {
          logMessage(ERROR, "no devices found to load drivers from");
      }
+
      return numDevices;
  }


Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux