This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: variable âsomethingâ set but not used [-Wunused-but-set-variable]
>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.