FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 03-05-2010, 08:33 AM
Martin Sivak
 
Default If no devices were found do not SIGSEGV (#567939)

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

--
1.6.6.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-05-2010, 08:50 AM
Hans de Goede
 
Default If no devices were found do not SIGSEGV (#567939)

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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-05-2010, 09:13 AM
Martin Sivak
 
Default If no devices were found do not SIGSEGV (#567939)

Hi,

Well.. this is ugly too And does not reflect the logic.. of course compiler would probably optimize it into my form anyways

> 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++) {

Martin

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-05-2010, 12:17 PM
Hans de Goede
 
Default If no devices were found do not SIGSEGV (#567939)

Hi,

On 03/05/2010 11:13 AM, Martin Sivak wrote:

Hi,

Well.. this is ugly too And does not reflect the logic.. of course compiler would probably optimize it into my form anyways



If you insist on doing things your way, please do it properly and but
the if and for on a separate line and indent the for block.

Regards,

Hans

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-05-2010, 12:48 PM
Ales Kozumplik
 
Default If no devices were found do not SIGSEGV (#567939)

On 03/05/2010 02:17 PM, Hans de Goede wrote:

Hi,

On 03/05/2010 11:13 AM, Martin Sivak wrote:

Hi,

Well.. this is ugly too And does not reflect the logic.. of course
compiler would probably optimize it into my form anyways



If you insist on doing things your way, please do it properly and but
the if and for on a separate line and indent the for block.



I think so too.

All the ways to write this are ugly, but this one is at least systematic.

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-05-2010, 01:17 PM
Martin Sivak
 
Default If no devices were found do not SIGSEGV (#567939)

Hi,

I do not insist, I just said both ways are ugly. And the systematic one is less readable than both unfortunately. Writing the for in a block may be the best way now that I think about it... (the one nobody of us considered here..)

Martin

----- "Hans de Goede" <hdegoede@redhat.com> wrote:

> Hi,
>
> On 03/05/2010 11:13 AM, Martin Sivak wrote:
> > Hi,
> >
> > Well.. this is ugly too And does not reflect the logic.. of
> course compiler would probably optimize it into my form anyways
> >
>
> If you insist on doing things your way, please do it properly and but
> the if and for on a separate line and indent the for block.
>
> Regards,
>
> Hans
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 03-05-2010, 02:02 PM
Chris Lumens
 
Default If no devices were found do not SIGSEGV (#567939)

> >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++) {

Or even:

devs = getDevices(DEVICE_DISK | DEVICE_CDROM);
if (!devs)
return 0;

I don't think missing the logging is such a big deal.

- Chris

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

Thread Tools




All times are GMT. The time now is 10:59 AM.

VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org