Re: Regarding unintialized variables

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

 



debian developer wrote:
> Hello,
> 
> Consider the following code snippet...
> 
>         const char *type;
> 
>         switch (rfkill->type) {
>         case RFKILL_TYPE_WLAN:
>                 type = "wlan";
>                 break;
>         case RFKILL_TYPE_BLUETOOTH:
>                 type = "bluetooth";
>                 break;
>         case RFKILL_TYPE_UWB:
>                 type = "ultrawideband";
>                 break;
>         case RFKILL_TYPE_WIMAX:
>                 type = "wimax";
>                 break;
>         default:
>                 BUG();
>         }
> 
> 
> It is clear that type will be set or BUG() called. Why don't we
> initialize type to NULL during declaration??
> 

or const char *uninitialized_var(type);

but IMO NULL is ok also.

> char *type  = NULL;
> 
> should fix the warning which i get
> warning: 'type' might be used uninitialized in this function
> 
> Please let me know so that i can submit a patch for that.
> 
> Thanks.
> 

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux