Bram Moolenaar wrote:
> Charles Campbell wrote:
>
>> I just noticed that there's a warning when compiling with gcc under
>> scientific linux:
>>
>> misc2.c: In function 'put_time':
>> misc2.c:6312: warning: ignoring return value of 'fwrite', declared with
>> attribute warn_unused_result
>>
>> In grep'ing through the patches, I see this one must have creeped in
>> back with patch#649, which in turn was trying to get rid of an annoying
>> compiler message for whatever compiler Michael Jarvis used. The
>> solution was to use (void)fwrite(...) in the put_time() function, but
>> gcc v4.4.7 gets grumpy even when explicitly told not to worry by the
>> (void) cast. IMHO gcc should let explicitly specified ignored values go
>> unmentioned, but there it is.
>>
>> Presumably, given the optimization and fortify settings, the function is
>> prototyped with __attribute_warn_unused_result__ .
>>
>> There are two solutions:
>>
>> * apply given patch: this removes the warning using gcc at the price of
>> a "silly" variable assignment. I'm afraid that I wouldn't be surprised
>> if some compiler out there flags silly as an unused variable, though.
>> * specify either -U_FORTIFY_SOURCE or -D_FORTIFY_SOURCE=0 . Probably
>> won't want to do that, I'd guess.
>>
>> I didn't see any -W... settings to turn this message off, btw.
> Let's do it the same way as with put_bytes(): return OK or FAIL
> depending on what fwrite() returns, which then gets ignored.
>
OK -- please try the patch which implements this.
Regards,
Chip Campbell
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
*** orig_misc2.c 2016-01-07 15:57:47.401235338 -0500
--- misc2.c 2016-01-07 16:42:11.863004712 -0500
***************
*** 6301,6307 ****
/*
* Write time_t to file "fd" in 8 bytes.
*/
! void
put_time(fd, the_time)
FILE *fd;
time_t the_time;
--- 6301,6307 ----
/*
* Write time_t to file "fd" in 8 bytes.
*/
! int
put_time(fd, the_time)
FILE *fd;
time_t the_time;
***************
*** 6309,6315 ****
char_u buf[8];
time_to_bytes(the_time, buf);
! (void)fwrite(buf, (size_t)8, (size_t)1, fd);
}
/*
--- 6309,6317 ----
char_u buf[8];
time_to_bytes(the_time, buf);
! if (fwrite(buf, (size_t)8, (size_t)1, fd) < ((size_t)8))
! return FAIL;
! return OK;
}
/*
*** proto/orig_misc2.pro 2016-01-07 16:46:47.662667891 -0500
--- proto/misc2.pro 2016-01-07 16:43:52.284702126 -0500
***************
*** 105,111 ****
time_t get8ctime __ARGS((FILE *fd));
char_u *read_string __ARGS((FILE *fd, int cnt));
int put_bytes __ARGS((FILE *fd, long_u nr, int len));
! void put_time __ARGS((FILE *fd, time_t the_time));
void time_to_bytes __ARGS((time_t the_time, char_u *buf));
int has_non_ascii __ARGS((char_u *s));
/* vim: set ft=c : */
--- 105,111 ----
time_t get8ctime __ARGS((FILE *fd));
char_u *read_string __ARGS((FILE *fd, int cnt));
int put_bytes __ARGS((FILE *fd, long_u nr, int len));
! int put_time __ARGS((FILE *fd, time_t the_time));
void time_to_bytes __ARGS((time_t the_time, char_u *buf));
int has_non_ascii __ARGS((char_u *s));
/* vim: set ft=c : */