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

Mahmood Naderan nt_mahmood@yahoo.com
Tue Jul 12 18:12:00 GMT 2011


>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@redhat.com>
To: gcc-help@gcc.gnu.org
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.



More information about the Gcc-help mailing list