GCC Bugzilla – Attachment 33152 Details for
Bug 61846
gcc assumes errno might be negative and issues unnecessary warning
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
sample program
readwarn.c (text/plain), 523 bytes, created by
Zbigniew Jędrzejewski-Szmek
on 2014-07-18 20:51:28 UTC
(
hide
)
Description:
sample program
Filename:
MIME Type:
Creator:
Zbigniew Jędrzejewski-Szmek
Created:
2014-07-18 20:51:28 UTC
Size:
523 bytes
patch
obsolete
>#include <stdio.h> >#include <unistd.h> >#include <errno.h> >#include <sys/types.h> >#include <sys/stat.h> >#include <fcntl.h> > >static int f(int fd, int *ans) { > int var, r; > > r = read(fd, &var, sizeof(var)); > if (r < 0) > return -errno; > if (r != sizeof(var)) > return -EIO; > > *ans = var; > return 0; >} > >int main(int argc, char **argv) { > int ans, fd; > > fd = open(argv[1], O_RDONLY); > if (f(fd, &ans) < 0) > printf("error"); > else > printf("ans: %d", ans); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 61846
:
33148
|
33150
|
33151
| 33152