Dan Nicolaescu wrote:
CID: 29
Checker: NEGATIVE_RETURNS (help)
File: emacs/lib-src/movemail.c
Function: main
Description: Tracked variable "nread" was passed to a negative sink.
463 {
464 char buf[1024];
465
466 while (1)
467 {
Event negative_return_fn: Called negative-returning function "read"
Event var_assign: NEGATIVE return value of "read" assigned to signed variable
"nread"
Also see events: [var_assign][negative_returns]
468 nread = read (indesc, buf, sizeof buf);
Event negative_returns: Tracked variable "nread" was passed to a negative sink.
Also see events: [negative_return_fn][var_assign]
469 if (nread != write (outdesc, buf, nread))
470 {
471 int saved_errno = errno;
472 unlink (outname);
473 errno = saved_errno;
474 pfatal_with_name (outname);
475 }
476 if (nread < sizeof buf)
477 break;
Is it portable to just pass "nread" to write and compare the return
values? Maybe "nread" can be checked before?
nread might be -1 on error from read, so then the call to write would be
bad, as the third argument is a size_t (unsigned) so -1 becomes a large
value. Better is to check for -1 and 0 (end of file) before doing the
write.
Jan D.
_______________________________________________
emacs-pretest-bug mailing list
emacs-pretest-bug@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug