Charles Campbell wrote:
> Bram Moolenaar wrote:
> > Patch 7.2.041-7.2.048 (not sure which one)
>
> Hello!
>
> I'm starting to get some warnings that I didn't used to get...
>
> gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
> -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include
> -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0
> -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
> -I/usr/include/freetype2 -I/usr/include/libpng12 -g -O2
> -D_FORTIFY_SOURCE=1 -I/usr/include64 -D_REENTRANT -D_GNU_SOURCE
> -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
> -I/usr/include/gdbm
> -I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE
> -I/usr/include/python2.4 -pthread -o objects/spell.o spell.c
> spell.c: In function 'write_vim_spell':
> spell.c:7958: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:7969: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8019: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8030: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8116: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8134: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8138: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8163: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8179: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8235: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8238: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c:8262: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
> spell.c: In function 'write_spell_prefcond':
> spell.c:9909: warning: ignoring return value of 'fwrite', declared with
> attribute warn_unused_result
>
> I tried preceding the calls to fwrite() with (void) casts, but that
> didn't remove the warnings. Putting
> int nfw;
> in the write_vim_spell() and write_spell_prefcond() functions and doing
> nfw= fwrite(...)
> did remove the warnings.
This is unrelated to patches. Vim checks writing the final byte, that
should be good enough.
Try if the patch below avoids the warnings.
*** ../vim-7.2.049/src/spell.c Mon Aug 25 04:12:38 2008
--- src/spell.c Thu Nov 20 17:28:01 2008
***************
*** 7926,7931 ****
--- 7926,7933 ----
char_u *p;
int rr;
int retval = OK;
+ int fwv = 1; /* collect return value of fwrite() to avoid
+ warnings from picky compiler */
fd = mch_fopen((char *)fname, "w");
if (fd == NULL)
***************
*** 7936,7946 ****
/* <HEADER>: <fileID> <versionnr> */
/* <fileID> */
! if (fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd) != 1)
! {
! EMSG(_(e_write));
! retval = FAIL;
! }
putc(VIMSPELLVERSION, fd); /*
<versionnr> */
/*
--- 7938,7944 ----
/* <HEADER>: <fileID> <versionnr> */
/* <fileID> */
! fwv &= fwrite(VIMSPELLMAGIC, VIMSPELLMAGICL, (size_t)1, fd);
putc(VIMSPELLVERSION, fd); /*
<versionnr> */
/*
***************
*** 7955,7961 ****
i = (int)STRLEN(spin->si_info);
put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
! fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
}
/* SN_REGION: <regionname> ...
--- 7953,7959 ----
i = (int)STRLEN(spin->si_info);
put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
! fwv &= fwrite(spin->si_info, (size_t)i, (size_t)1, fd); /* <infotext> */
}
/* SN_REGION: <regionname> ...
***************
*** 7966,7972 ****
putc(SNF_REQUIRED, fd); /* <sectionflags> */
l = spin->si_region_count * 2;
put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
! fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
/* <regionname> ... */
regionmask = (1 << spin->si_region_count) - 1;
}
--- 7964,7970 ----
putc(SNF_REQUIRED, fd); /* <sectionflags> */
l = spin->si_region_count * 2;
put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
! fwv &= fwrite(spin->si_region_name, (size_t)l, (size_t)1, fd);
/* <regionname> ... */
regionmask = (1 << spin->si_region_count) - 1;
}
***************
*** 8016,8022 ****
}
put_bytes(fd, (long_u)l, 2); /* <folcharslen> */
! fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
}
/* SN_MIDWORD: <midword> */
--- 8014,8020 ----
}
put_bytes(fd, (long_u)l, 2); /* <folcharslen> */
! fwv &= fwrite(folchars, (size_t)l, (size_t)1, fd); /* <folchars> */
}
/* SN_MIDWORD: <midword> */
***************
*** 8027,8033 ****
i = (int)STRLEN(spin->si_midword);
put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
! fwrite(spin->si_midword, (size_t)i, (size_t)1, fd); /* <midword> */
}
/* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
--- 8025,8032 ----
i = (int)STRLEN(spin->si_midword);
put_bytes(fd, (long_u)i, 4); /* <sectionlen> */
! fwv &= fwrite(spin->si_midword, (size_t)i, (size_t)1, fd);
! /* <midword> */
}
/* SN_PREFCOND: <prefcondcnt> <prefcond> ... */
***************
*** 8113,8119 ****
p = rr == 1 ? ftp->ft_from : ftp->ft_to;
l = (int)STRLEN(p);
putc(l, fd);
! fwrite(p, l, (size_t)1, fd);
}
}
--- 8112,8118 ----
p = rr == 1 ? ftp->ft_from : ftp->ft_to;
l = (int)STRLEN(p);
putc(l, fd);
! fwv &= fwrite(p, l, (size_t)1, fd);
}
}
***************
*** 8131,8141 ****
/* <sectionlen> */
put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */
! fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
l = (int)STRLEN(spin->si_sofoto);
put_bytes(fd, (long_u)l, 2); /* <sofotolen> */
! fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */
}
/* SN_WORDS: <word> ...
--- 8130,8140 ----
/* <sectionlen> */
put_bytes(fd, (long_u)l, 2); /* <sofofromlen> */
! fwv &= fwrite(spin->si_sofofr, l, (size_t)1, fd); /* <sofofrom> */
l = (int)STRLEN(spin->si_sofoto);
put_bytes(fd, (long_u)l, 2); /* <sofotolen> */
! fwv &= fwrite(spin->si_sofoto, l, (size_t)1, fd); /* <sofoto> */
}
/* SN_WORDS: <word> ...
***************
*** 8160,8166 ****
l = (int)STRLEN(hi->hi_key) + 1;
len += l;
if (round == 2) /* <word> */
! fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
--todo;
}
if (round == 1)
--- 8159,8165 ----
l = (int)STRLEN(hi->hi_key) + 1;
len += l;
if (round == 2) /* <word> */
! fwv &= fwrite(hi->hi_key, (size_t)l, (size_t)1, fd);
--todo;
}
if (round == 1)
***************
*** 8176,8182 ****
putc(0, fd); /* <sectionflags> */
l = spin->si_map.ga_len;
put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
! fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
/* <mapstr> */
}
--- 8175,8181 ----
putc(0, fd); /* <sectionflags> */
l = spin->si_map.ga_len;
put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
! fwv &= fwrite(spin->si_map.ga_data, (size_t)l, (size_t)1, fd);
/* <mapstr> */
}
***************
*** 8232,8241 ****
{
p = ((char_u **)(spin->si_comppat.ga_data))[i];
putc((int)STRLEN(p), fd); /* <comppatlen> */
! fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);/* <comppattext> */
}
/* <compflags> */
! fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
(size_t)1, fd);
}
--- 8231,8241 ----
{
p = ((char_u **)(spin->si_comppat.ga_data))[i];
putc((int)STRLEN(p), fd); /* <comppatlen> */
! fwv &= fwrite(p, (size_t)STRLEN(p), (size_t)1, fd);
! /* <comppattext> */
}
/* <compflags> */
! fwv &= fwrite(spin->si_compflags, (size_t)STRLEN(spin->si_compflags),
(size_t)1, fd);
}
***************
*** 8259,8265 ****
l = (int)STRLEN(spin->si_syllable);
put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
! fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd); /* <syllable> */
}
/* end of <SECTIONS> */
--- 8259,8266 ----
l = (int)STRLEN(spin->si_syllable);
put_bytes(fd, (long_u)l, 4); /* <sectionlen> */
! fwv &= fwrite(spin->si_syllable, (size_t)l, (size_t)1, fd);
! /* <syllable> */
}
/* end of <SECTIONS> */
***************
*** 8295,8307 ****
(void)put_node(fd, tree, 0, regionmask, round == 3);
}
! /* Write another byte to check for errors. */
if (putc(0, fd) == EOF)
retval = FAIL;
if (fclose(fd) == EOF)
retval = FAIL;
return retval;
}
--- 8296,8313 ----
(void)put_node(fd, tree, 0, regionmask, round == 3);
}
! /* Write another byte to check for errors (file system full). */
if (putc(0, fd) == EOF)
retval = FAIL;
if (fclose(fd) == EOF)
retval = FAIL;
+ if (fwv != 1)
+ retval = FAIL;
+ if (retval == FAIL)
+ EMSG(_(e_write));
+
return retval;
}
***************
*** 9890,9895 ****
--- 9896,9902 ----
char_u *p;
int len;
int totlen;
+ int x = 1; /* collect return value of fwrite() */
if (fd != NULL)
put_bytes(fd, (long_u)gap->ga_len, 2); /* <prefcondcnt> */
***************
*** 9906,9912 ****
if (fd != NULL)
{
fputc(len, fd);
! fwrite(p, (size_t)len, (size_t)1, fd);
}
totlen += len;
}
--- 9913,9919 ----
if (fd != NULL)
{
fputc(len, fd);
! x &= fwrite(p, (size_t)len, (size_t)1, fd);
}
totlen += len;
}
--
If I tell you "you have a beautiful body", would you hold it against me?
/// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---