Re: Regarding unintialized variables

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

 



Hi...

On Sat, May 3, 2008 at 1:41 PM, debian developer <debiandev@xxxxxxxxx> 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??
>
>  char *type  = NULL;
>
>  should fix the warning which i get
>  warning: 'type' might be used uninitialized in this function

I think that's because the pointer will live on .bss...and .bss
variables will be assigned zero pages. Then, when it will get
referenced for the first time, demand paging mechanism will be
triggered.

My point is: NULL, in this case, is implicitly assigned to that pointer.

regards,

Mulyadi.

--
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