Re: variable ‘something’ set but not used [-Wunused-but-set-variable]

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

 



>The message is correct.  fullpath_length is set, but not used.
 
Hi
What is this then

     fullpath_length = strlen(fullpath);     // variable is used here

isn't a usage of fullpath_length?


// Naderan *Mahmood;


----- Original Message -----
From: Andrew Haley <aph@xxxxxxxxxx>
To: gcc-help@xxxxxxxxxxx
Cc: 
Sent: Tuesday, July 12, 2011 10:38 PM
Subject: Re: variable ‘something’ set but not used [-Wunused-but-set-variable]

On 07/12/2011 07:01 PM, Mahmood Naderan wrote:
> 
> 
> dear all,
> GCC-4.6 says this warning
>    
> 
> syscall.c:1011:15: warning: variable ‘fullpath_length’ set but not used [-Wunused-but-set-variable]
> 
> 
> However in the code, I see
> 
>         int length, fullpath_length;    // warning at this line
>         int host_fd;
>         struct fd_t *fd;
> 
>         /* Read parameters */
>         pfilename = isa_regs->ebx;
>         flags = isa_regs->ecx;
>         mode = isa_regs->edx;
>         length = mem_read_string(isa_mem, pfilename, MAX_PATH_SIZE, filename);
>         if (length >= MAX_PATH_SIZE)
>             fatal("syscall open: maximum path length exceeded");
>         ld_get_full_path(isa_ctx, filename, fullpath, MAX_PATH_SIZE);
>         fullpath_length = strlen(fullpath);     // variable is used here
> 
>  
> As you can see fullpath_length is defined as 'int' and is used at the end of the code.
> Any way to fix that?

The message is correct.  fullpath_length is set, but not used.

Andrew.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux