summaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorCollin Funk <collin.funk1@gmail.com>2025-09-28 15:29:51 -0700
committerCollin Funk <collin.funk1@gmail.com>2025-09-29 17:01:54 -0700
commite465aeed597ed504edf88183ec8ccf31fd5b0c56 (patch)
treebcdddc1c4ca9abc19c46d8a7b43c5e480d15a52d /manual
parentae77ce91c8c0e928e0722218d7f30c2ab073cdc4 (diff)
manual: Fix compiler errors in filesrv example.
Previously this file failed to compile with the following errors: $ gcc manual/examples/filesrv.c manual/examples/filesrv.c: In function ‘main’: manual/examples/filesrv.c:37:3: error: implicit declaration of function ‘unlink’ [-Wimplicit-function-declaration] 37 | unlink (SERVER); | ^~~~~~ manual/examples/filesrv.c:40:10: error: implicit declaration of function ‘make_named_socket’ [-Wimplicit-function-declaration] 40 | sock = make_named_socket (SERVER); | ^~~~~~~~~~~~~~~~~ manual/examples/filesrv.c:46:54: error: passing argument 6 of ‘recvfrom’ from incompatible pointer type [-Wincompatible-pointer-types] 46 | (struct sockaddr *) & name, &size); | ^~~~~ | | | size_t * {aka long unsigned int *} In file included from manual/examples/filesrv.c:21: /usr/include/sys/socket.h:165:48: note: expected ‘socklen_t * restrict’ {aka ‘unsigned int * restrict’} but argument is of type ‘size_t *’ {aka ‘long unsigned int *’} 165 | socklen_t *__restrict __addr_len); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ This patch fixes the missing declaration for unlink and uses 'socklen_t *' for the fourth argument of recv from. The make_named_socket function is defined in the manual. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'manual')
-rw-r--r--manual/examples/filesrv.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/manual/examples/filesrv.c b/manual/examples/filesrv.c
index 09c80c5999..9b39350568 100644
--- a/manual/examples/filesrv.c
+++ b/manual/examples/filesrv.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <unistd.h>
#define SERVER "/tmp/serversocket"
#define MAXMSG 512
@@ -30,7 +31,7 @@ main (void)
int sock;
char message[MAXMSG];
struct sockaddr_un name;
- size_t size;
+ socklen_t size;
int nbytes;
/* Remove the filename first, it's ok if the call fails */