This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
variable âsomethingâ set but not used [-W unused-but-set-variable]
- From: Mahmood Naderan <nt_mahmood at yahoo dot com>
- To: gcc <gcc-help at gcc dot gnu dot org>
- Date: Tue, 12 Jul 2011 11:01:58 -0700 (PDT)
- Subject: variable âsomethingâ set but not used [-W unused-but-set-variable]
- References: <1310469108.68554.YahooMailNeo@web111710.mail.gq1.yahoo.com>
- Reply-to: Mahmood Naderan <nt_mahmood at yahoo dot com>
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?
// Naderan *Mahmood;