mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
fuse: Don't call fclose(NULL) on error paths
Various errors like this:
In function ‘test_fuse’,
inlined from ‘main’ at test-fuse.c:133:11:
test-fuse.c:274:5: error: argument 1 null where non-null expected [-Werror=nonnull]
274 | fclose (fp);
| ^~~~~~~~~~~
In file included from test-fuse.c:26:
/usr/include/stdio.h: In function ‘main’:
/usr/include/stdio.h:183:12: note: in a call to function ‘fclose’ declared ‘nonnull’
183 | extern int fclose (FILE *__stream) __nonnull ((1));
| ^~~~~~
This commit is contained in:
@@ -271,7 +271,6 @@ test_fuse (void)
|
|||||||
fp = fopen ("hello.txt", "r");
|
fp = fopen ("hello.txt", "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
perror ("open: hello.txt");
|
perror ("open: hello.txt");
|
||||||
fclose (fp);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (getline (&line, &len, fp) == -1) {
|
if (getline (&line, &len, fp) == -1) {
|
||||||
@@ -289,7 +288,6 @@ test_fuse (void)
|
|||||||
fp = fopen ("world.txt", "r");
|
fp = fopen ("world.txt", "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
perror ("open: world.txt");
|
perror ("open: world.txt");
|
||||||
fclose (fp);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (getline (&line, &len, fp) == -1) {
|
if (getline (&line, &len, fp) == -1) {
|
||||||
@@ -352,7 +350,6 @@ test_fuse (void)
|
|||||||
fp = fopen ("new", "w");
|
fp = fopen ("new", "w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
perror ("open: new");
|
perror ("open: new");
|
||||||
fclose (fp);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
@@ -615,7 +612,6 @@ test_fuse (void)
|
|||||||
fp = fopen ("new.txt", "w");
|
fp = fopen ("new.txt", "w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
perror ("open: new.txt");
|
perror ("open: new.txt");
|
||||||
fclose (fp);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (u = 0; u < 1000; ++u) {
|
for (u = 0; u < 1000; ++u) {
|
||||||
|
|||||||
Reference in New Issue
Block a user