Commit d92d6ae7 authored by Rusty Russell's avatar Rusty Russell

Fix new glibc warnings about warn_unused_result.

parent 49b125f3
......@@ -11,6 +11,7 @@
#include "antithread.h"
#include <ccan/noerr/noerr.h>
#include <ccan/talloc/talloc.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/alloc/alloc.h>
/* FIXME: Valgrind support should be possible for some cases. Tricky
......@@ -290,7 +291,7 @@ struct athread *at_spawn(struct at_pool *pool, void *arg, char *cmdline[])
execvp(argv[0], argv);
err = errno;
write(pool->parent_wfd, &err, sizeof(err));
write_all(pool->parent_wfd, &err, sizeof(err));
exit(1);
}
......
#include <stdio.h>
#include <string.h>
#include "config.h"
/**
* read_write_all - read_all and write_all routines.
*
* Successful read and write calls may only partly complete if a
* signal is received or they are not operating on a normal file.
*
* read_all() and write_all() do the looping for you.
*
* Example:
* #include <err.h>
* #include <stdio.h>
* #include <unistd.h>
* #include <ccan/read_write_all/read_write_all.h>
*
* #define BUFFER_SIZE 10
* int main(int argc, char *argv[])
* {
* char buffer[BUFFER_SIZE+1];
*
* if (!read_all(STDIN_FILENO, buffer, BUFFER_SIZE))
* err(1, "Could not read %u characters", BUFFER_SIZE);
* buffer[BUFFER_SIZE] = '\0';
* printf("I read '%.*s'\n", BUFFER_SIZE, buffer);
* return 0;
* }
*
* Licence: LGPL (2 or any later version)
*/
int main(int argc, char *argv[])
{
if (argc != 2)
return 1;
if (strcmp(argv[1], "depends") == 0) {
return 0;
}
return 1;
}
#include "read_write_all.h"
#include <unistd.h>
#include <errno.h>
bool write_all(int fd, const void *data, size_t size)
{
while (size) {
ssize_t done;
done = write(fd, data, size);
if (done < 0 && errno == EINTR)
continue;
if (done <= 0)
return false;
data += done;
size -= done;
}
return true;
}
bool read_all(int fd, void *data, size_t size)
{
while (size) {
ssize_t done;
done = read(fd, data, size);
if (done < 0 && errno == EINTR)
continue;
if (done <= 0)
return false;
data += done;
size -= done;
}
return true;
}
#ifndef _CCAN_READ_WRITE_H
#define _CCAN_READ_WRITE_H
#include <stddef.h>
#include <stdbool.h>
bool write_all(int fd, const void *data, size_t size);
bool read_all(int fd, void *data, size_t size);
#endif /* _CCAN_READ_WRITE_H */
......@@ -105,7 +105,8 @@ _gen_result(int ok, const char *func, char *file, unsigned int line,
expansions on it */
if(test_name != NULL) {
va_start(ap, test_name);
vasprintf(&local_test_name, test_name, ap);
if (vasprintf(&local_test_name, test_name, ap) < 0)
local_test_name = NULL;
va_end(ap);
/* Make sure the test name contains more than digits
......@@ -363,7 +364,8 @@ skip(unsigned int n, char *fmt, ...)
LOCK;
va_start(ap, fmt);
vasprintf(&skip_msg, fmt, ap);
if (vasprintf(&skip_msg, fmt, ap) < 0)
skip_msg = NULL;
va_end(ap);
while(n-- > 0) {
......@@ -386,7 +388,8 @@ todo_start(char *fmt, ...)
LOCK;
va_start(ap, fmt);
vasprintf(&todo_msg, fmt, ap);
if (vasprintf(&todo_msg, fmt, ap) < 0)
todo_msg = NULL;
va_end(ap);
todo = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment