[netcf-devel] [PATCH] Fix build errors when using -Werror=unused-but-set-variable
Laine Stump
laine at laine.org
Wed Oct 12 16:01:36 UTC 2011
On 10/12/2011 10:46 AM, Eric Blake wrote:
> On 10/11/2011 10:20 PM, Laine Stump wrote:
>> From: Laine Stump<laine at vlap.laine.org>
>>
>> The following errors appeared when I began building on Fedora 16. In
>> all cases, the variables really are never used, so they've been
>> removed.
>>
>> +++ b/src/drv_redhat.c
>> @@ -166,11 +166,10 @@ static char *find_ifcfg_path_by_hwaddr(struct
>> netcf *ncf, const char *mac) {
>> * interface by checking for an entry 'DEVICE=NAME'
>> */
>> static char *find_ifcfg_path_by_device(struct netcf *ncf, const
>> char *name) {
>> - struct augeas *aug = NULL;
>> int ndevs = 0;
>> char **devs = NULL;
>>
>> - aug = get_augeas(ncf);
>> + get_augeas(ncf);
>
> I had to look, but it does indeed look like get_augeas is useful for
> its side effects of initializing a member of ncf. But are you risking
> a NULL dereference if the initialization failed? That is, should you
> be using ERR_THROW(!get_augeas(ncf), ncf, E..., "failed to get
> augeas") instead of blindly ignoring the return value?
>
That's what the "ERR_BAIL(ncf)" immediately following get_augeas(ncf)
does - whenever a lower level function throws an error, it sets a flag
in the ncf object, so on return callers can just do "ERR_BAIL(ncf)"; if
an error has happened, ERR_BAIL() jumps to error;.
More information about the netcf-devel
mailing list