diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-09-23 14:18:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-09-23 14:18:06 +0000 |
commit | 011d784f6c8d6c305e29bee1374a240ab9e4d7c7 (patch) | |
tree | d0edfed88a9d7fc92a4ef487f41007f0887d6f8f /src/examples | |
parent | c63ac7db4ebc38713aa5d5e2edf52c27200003d8 (diff) | |
download | libmicrohttpd-011d784f6c8d6c305e29bee1374a240ab9e4d7c7.tar.gz libmicrohttpd-011d784f6c8d6c305e29bee1374a240ab9e4d7c7.zip |
add return value checks for a few more system calls in testcases and examples
Diffstat (limited to 'src/examples')
-rw-r--r-- | src/examples/fileserver_example_external_select.c | 6 | ||||
-rw-r--r-- | src/examples/post_example.c | 6 | ||||
-rw-r--r-- | src/examples/timeout.c | 21 |
3 files changed, 22 insertions, 11 deletions
diff --git a/src/examples/fileserver_example_external_select.c b/src/examples/fileserver_example_external_select.c index f3f19206..6f7d83c4 100644 --- a/src/examples/fileserver_example_external_select.c +++ b/src/examples/fileserver_example_external_select.c | |||
@@ -159,7 +159,11 @@ main (int argc, char *const *argv) | |||
159 | tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000LL)) * 1000LL; | 159 | tv.tv_usec = (mhd_timeout - (tv.tv_sec * 1000LL)) * 1000LL; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | select (max + 1, &rs, &ws, &es, &tv); | 162 | if (-1 == select (max + 1, &rs, &ws, &es, &tv)) |
163 | { | ||
164 | if (EINTR != errno) | ||
165 | abort (); | ||
166 | } | ||
163 | MHD_run (d); | 167 | MHD_run (d); |
164 | } | 168 | } |
165 | MHD_stop_daemon (d); | 169 | MHD_stop_daemon (d); |
diff --git a/src/examples/post_example.c b/src/examples/post_example.c index c04ee7cd..d0872cc5 100644 --- a/src/examples/post_example.c +++ b/src/examples/post_example.c | |||
@@ -741,7 +741,11 @@ main (int argc, char *const *argv) | |||
741 | } | 741 | } |
742 | else | 742 | else |
743 | tvp = NULL; | 743 | tvp = NULL; |
744 | select (max + 1, &rs, &ws, &es, tvp); | 744 | if (-1 == select (max + 1, &rs, &ws, &es, tvp)) |
745 | { | ||
746 | if (EINTR != errno) | ||
747 | abort (); | ||
748 | } | ||
745 | MHD_run (d); | 749 | MHD_run (d); |
746 | } | 750 | } |
747 | MHD_stop_daemon (d); | 751 | MHD_stop_daemon (d); |
diff --git a/src/examples/timeout.c b/src/examples/timeout.c index 7f6f249a..5025d26b 100644 --- a/src/examples/timeout.c +++ b/src/examples/timeout.c | |||
@@ -21,9 +21,9 @@ answer_to_connection(void *cls, | |||
21 | response = MHD_create_response_from_buffer (strlen(page), | 21 | response = MHD_create_response_from_buffer (strlen(page), |
22 | (void *) page, | 22 | (void *) page, |
23 | MHD_RESPMEM_PERSISTENT); | 23 | MHD_RESPMEM_PERSISTENT); |
24 | MHD_add_response_header(response, | 24 | MHD_add_response_header (response, |
25 | MHD_HTTP_HEADER_CONTENT_TYPE, | 25 | MHD_HTTP_HEADER_CONTENT_TYPE, |
26 | "text/html"); | 26 | "text/html"); |
27 | ret = MHD_queue_response (connection, | 27 | ret = MHD_queue_response (connection, |
28 | MHD_HTTP_OK, | 28 | MHD_HTTP_OK, |
29 | response); | 29 | response); |
@@ -32,15 +32,18 @@ answer_to_connection(void *cls, | |||
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
35 | int main() | 35 | int |
36 | main (int argc, | ||
37 | char **argv) | ||
36 | { | 38 | { |
37 | struct MHD_Daemon *daemon; | 39 | struct MHD_Daemon *daemon; |
38 | 40 | ||
39 | daemon = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, | 41 | daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION, |
40 | PORT, NULL, NULL, | 42 | PORT, |
41 | &answer_to_connection, NULL, | 43 | NULL, NULL, |
42 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 3, | 44 | &answer_to_connection, NULL, |
43 | MHD_OPTION_END); | 45 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 3, |
46 | MHD_OPTION_END); | ||
44 | if (NULL == daemon) | 47 | if (NULL == daemon) |
45 | return 1; | 48 | return 1; |
46 | getchar(); | 49 | getchar(); |