[PATCH btbridge v4 1/6] Initialise variable to avoid using it uninitialised

Andrew Jeffery andrew at aj.id.au
Thu May 19 13:10:49 AEST 2016


Hi Cyril,

On Tue, 2016-05-03 at 20:10 -0500, OpenBMC Patches wrote:
> From: Cyril Bur <cyril.bur at au1.ibm.com>
> 
> Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
> ---
>  btbridged.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/btbridged.c b/btbridged.c
> index fe692bb..3e261a9 100644
> --- a/btbridged.c
> +++ b/btbridged.c
> @@ -489,7 +489,7 @@ static int dispatch_sd_bus(struct btbridged_context *context)
>  static int dispatch_bt(struct btbridged_context *context)
>  {
>  	int err = 0;
> -	int r;
> +	int r = 0;
>  
>  	assert(context);
>  

Building with this patch and native GCC* gives errors:

    $ KERNEL_HEADERS=../../linux/ast2400/include/uapi/ make
    cc  -Wall -O2 -g -I../../linux/ast2400/include/uapi/    btbridged.c  -lsystemd -o btbridged
    btbridged.c: In function ‘main’:
    btbridged.c:590:6: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       if (r < 0)
          ^
    btbridged.c:342:6: note: ‘r’ was declared here
      int r, len;
          ^

That's weird, because the note isn't relevant to the function of line
that generated the warning. However, the 'r' defined in bt_host_write()
suffers the same initialisation issue. Initialising it gives me a build
with no warnings so maybe it's worth doing that here also?

Otherwise,

Acked-by: Andrew Jeffery <andrew at aj.id.au>

Cheers,

Andrew

* $ gcc --version
gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20160519/8cd247b5/attachment.sig>


More information about the openbmc mailing list