Re: parent (GUdevDevice) uninitialized in _update_s390_subchannels



Le vendredi 05 novembre 2010 à 11:15 +0000, Marc Herbert a écrit :
> >> `nm-device-ethernet.c
> >> cc1: warnings being treated as errors
> >> nm-device-ethernet.c: In function ‘constructor’:
> >> nm-device-ethernet.c:400:5: error: ‘parent’ may be used uninitialized in
> >> this function
> > 
> > Attached is the patch I applied:
> > 
> > -	GUdevDevice *parent;
> > +	GUdevDevice *parent = NULL; // disable gcc warning because...?
> > 
> > 
> > This just buries the warning. Are you sure the warning is wrong? If yes it deserves a comment.
> 
> The proper way to get rid of this warning is not to group declarations at the top of the block:
> 
> <http://stackoverflow.com/questions/288441/variable-declaration-placement-in-c/4105334#4105334>

On the contrary, I am sure the warning is there for a good reason, that
is, not to assume particular values for uninitialized variables. I
wouldn't mind adding a comment but it's pretty clear to me that it's
just making sure we know what the starting value is for that variable
before it's used -- and errors in the subsequent calls will return NULL
as well.

Also, while I agree declarations don't have to be grouped at the top, I
don't agree that it would make any difference in this case.

-- 
Mathieu Trudel-Lapierre <mathieu tl gmail com>
Freenode: cyphermox, Jabber: mathieu tl gmail com
4096R/EE018C93 1967 8F7D 03A1 8F38 732E  FF82 C126 33E1 EE01 8C93

Attachment: signature.asc
Description: This is a digitally signed message part



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