Have examples compile warning-free at -O3

This commit is contained in:
Nigel Tao committed 2018-05-25 11:40:05 +10:00
1 parent 97e73c10c8
commit 4926e98956
2 files changed
+13 -7

No files matched your search

+7 -4
View File
@@ -79,6 +79,9 @@ uint32_t num_loops_remaining = 0;
wuffs_base__flicks cumulative_delay_micros = 0; wuffs_base__flicks cumulative_delay_micros = 0;
// ignore_return_value suppresses errors from -Wall -Werror.
static void ignore_return_value(int ignored) {}
const char* read_stdin() { const char* read_stdin() {
while (src_len < SRC_BUFFER_SIZE) { while (src_len < SRC_BUFFER_SIZE) {
const int stdin_fd = 0; const int stdin_fd = 0;
@@ -184,7 +187,7 @@ void print_ascii_art(wuffs_base__image_buffer* ib) {
} }
*p++ = '\n'; *p++ = '\n';
} }
write(stdout_fd, print_buffer, p - print_buffer); ignore_return_value(write(stdout_fd, print_buffer, p - print_buffer));
} }
void print_color_art(wuffs_base__image_buffer* ib) { void print_color_art(wuffs_base__image_buffer* ib) {
@@ -212,7 +215,7 @@ void print_color_art(wuffs_base__image_buffer* ib) {
} }
p = append_pascal_string(p, reset_color_pascal_string); p = append_pascal_string(p, reset_color_pascal_string);
write(stdout_fd, print_buffer, p - print_buffer); ignore_return_value(write(stdout_fd, print_buffer, p - print_buffer));
} }
// ---- // ----
@@ -330,8 +333,8 @@ const char* play() {
int fail(const char* msg) { int fail(const char* msg) {
const int stderr_fd = 2; const int stderr_fd = 2;
write(stderr_fd, msg, strnlen(msg, 4095)); ignore_return_value(write(stderr_fd, msg, strnlen(msg, 4095)));
write(stderr_fd, "\n", 1); ignore_return_value(write(stderr_fd, "\n", 1));
return 1; return 1;
} }
+6 -3
View File
@@ -51,6 +51,9 @@ for a C compiler $cc, such as clang or gcc.
char dst_buffer[DST_BUFFER_SIZE]; char dst_buffer[DST_BUFFER_SIZE];
char src_buffer[SRC_BUFFER_SIZE]; char src_buffer[SRC_BUFFER_SIZE];
// ignore_return_value suppresses errors from -Wall -Werror.
static void ignore_return_value(int ignored) {}
static const char* decode() { static const char* decode() {
wuffs_gzip__decoder dec; wuffs_gzip__decoder dec;
wuffs_gzip__decoder__initialize(&dec, WUFFS_VERSION, 0); wuffs_gzip__decoder__initialize(&dec, WUFFS_VERSION, 0);
@@ -80,7 +83,7 @@ static const char* decode() {
if (dst.wi) { if (dst.wi) {
// TODO: handle EINTR and other write errors; see "man 2 write". // TODO: handle EINTR and other write errors; see "man 2 write".
const int stdout_fd = 1; const int stdout_fd = 1;
write(stdout_fd, dst_buffer, dst.wi); ignore_return_value(write(stdout_fd, dst_buffer, dst.wi));
} }
if (s == WUFFS_GZIP__STATUS_OK) { if (s == WUFFS_GZIP__STATUS_OK) {
@@ -98,8 +101,8 @@ static const char* decode() {
int fail(const char* msg) { int fail(const char* msg) {
const int stderr_fd = 2; const int stderr_fd = 2;
write(stderr_fd, msg, strnlen(msg, 4095)); ignore_return_value(write(stderr_fd, msg, strnlen(msg, 4095)));
write(stderr_fd, "\n", 1); ignore_return_value(write(stderr_fd, "\n", 1));
return 1; return 1;
} }