diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 16:05:46 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 16:05:46 +0200 |
commit | 08ce54211ce4b8d6092321ca1b28773a680ddc45 (patch) | |
tree | 9cf7eb2702a408743d59e207e24f8fb1e5ada31d /src | |
parent | 795ffc5e62e8ba383575dbcd9943a580d4bd3358 (diff) |
Added missing function prototype signatures.
Corrected socket_broadcast name to socket_broadcast4 in socket_if.h.
Added const to fmt_str.
Diffstat (limited to 'src')
-rw-r--r-- | src/alloc.c | 7 | ||||
-rw-r--r-- | src/base64.c | 2 | ||||
-rw-r--r-- | src/buffer.c | 2 | ||||
-rw-r--r-- | src/byte.c | 23 | ||||
-rw-r--r-- | src/dnsstub/dns_transmit.c | 6 | ||||
-rw-r--r-- | src/fmt.c | 2 | ||||
-rw-r--r-- | src/getoptb.c | 2 | ||||
-rw-r--r-- | src/sig.c | 20 |
8 files changed, 39 insertions, 25 deletions
diff --git a/src/alloc.c b/src/alloc.c index cee09ac..7e4ccb4 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -17,7 +17,7 @@ static aligned realspace[SPACE / ALIGNMENT]; #define space ((char *)realspace) static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */ -/*@null@*/ /*@out@*/ char *alloc(unsigned int n) +void *alloc(unsigned int n) { char *x; @@ -38,15 +38,16 @@ static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */ return x; } -void alloc_free(char *x) +void alloc_free(void *x) { if (x >= space) if (x < space + SPACE) return; /* XXX: assuming that pointers are flat */ free(x); } -int alloc_re(char **x, unsigned int m, unsigned int n) +int alloc_re(void *a, unsigned int m, unsigned int n) { + char **x = a; char *y; y = alloc(n); diff --git a/src/base64.c b/src/base64.c index 33b54e6..17847d9 100644 --- a/src/base64.c +++ b/src/base64.c @@ -10,7 +10,7 @@ @brief base64 en+decoding of strings */ -static char *b64alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char *b64alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; #define B64PAD '=' /* returns 0 ok, 1 illegal, -1 problem */ diff --git a/src/buffer.c b/src/buffer.c index 036b298..f094213 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -21,7 +21,7 @@ void buffer_init(buffer *s, ssize_t (*op)(), int fd, char *buf, size_t len) s->n = len; } -ssize_t buffer_0_read(int fd, char *buf, size_t len) +static ssize_t buffer_0_read(int fd, char *buf, size_t len) { if (buffer_flush(buffer_1) == -1) return -1; return read(fd, buf, len); @@ -22,8 +22,11 @@ unsigned int byte_chr(char *s, unsigned int n, int c) return t - s; } -void byte_copy(char *to, unsigned int n, char *from) +void byte_copy(void *a, unsigned int n, const void *b) { + char *to = a; + const char *from = b; + for (;;) { // clang-format off if (!n) { return; } *to++ = *from++; --n; @@ -34,10 +37,10 @@ void byte_copy(char *to, unsigned int n, char *from) } } -void byte_copyr(char *to, unsigned int n, char *from) +void byte_copyr(void *a, unsigned int n, const void *b) { - to += n; - from += n; + char *to = a + n; + const char *from = b + n; for (;;) { // clang-format off @@ -49,8 +52,11 @@ void byte_copyr(char *to, unsigned int n, char *from) } } -int byte_diff(char *s, unsigned int n, char *t) +int byte_diff(const void *a, unsigned int n, const void *b) { + const char *s = a; + const char *t = b; + for (;;) { // clang-format off if (!n) { return 0; } if (*s != *t) { break; } ++s; ++t; --n; @@ -80,8 +86,10 @@ unsigned int byte_rchr(char *s, unsigned int n, int c) return u - s; } -void byte_zero(char *s, unsigned int n) +void byte_zero(void *v, unsigned int n) { + char *s = v; + for (;;) { // clang-format off if (!n) { break; } *s++ = 0; --n; @@ -92,8 +100,9 @@ void byte_zero(char *s, unsigned int n) } } -void byte_fill(char *s, unsigned int n, int c) +void byte_fill(void *a, unsigned int n, int c) { + char *s = a; char ch = c; for (;;) { diff --git a/src/dnsstub/dns_transmit.c b/src/dnsstub/dns_transmit.c index 96eb38c..bc37791 100644 --- a/src/dnsstub/dns_transmit.c +++ b/src/dnsstub/dns_transmit.c @@ -61,7 +61,7 @@ int serverfailed(const char *buf, unsigned int len) return 0; } -int irrelevant(const struct dns_transmit *d, const char *buf, unsigned int len) +static int irrelevant(const struct dns_transmit *d, const char *buf, unsigned int len) { char out[12]; char *dn; @@ -142,7 +142,7 @@ int randombind4(struct dns_transmit *d) return DNS_COM; } -int thisudp(struct dns_transmit *d) +static int thisudp(struct dns_transmit *d) { const char *ip; @@ -210,7 +210,7 @@ int nextudp(struct dns_transmit *d) return thisudp(d); } -int thistcp(struct dns_transmit *d) +static int thistcp(struct dns_transmit *d) { struct taia now; const char *ip; @@ -7,7 +7,7 @@ @brief formating differnt inputs format for output printing */ -unsigned int fmt_str(char *s, char *t) +unsigned int fmt_str(char *s, const char *t) { unsigned int len; char ch; diff --git a/src/getoptb.c b/src/getoptb.c index 64ac8ca..e0f6118 100644 --- a/src/getoptb.c +++ b/src/getoptb.c @@ -15,7 +15,7 @@ int opterr = 1; char *optprogname = 0; -int getopt(int argc, char **argv, char *opts) +static int getopt(int argc, char **argv, char *opts) { int c; char *s; @@ -18,7 +18,8 @@ void sig_alarmunblock() { sig_unblock(SIGALRM); } -void sig_alarmcatch(f) void (*f)(); + +void sig_alarmcatch(void (*f)(int)) { sig_catch(SIGALRM, f); } @@ -53,7 +54,7 @@ void sig_blocknone() sigprocmask(SIG_SETMASK, &ss, (sigset_t *)0); } -void sig_catch(int sig, void (*f)()) +void sig_catch(int sig, void (*f)(int)) { struct sigaction sa; sa.sa_handler = f; @@ -90,7 +91,8 @@ void sig_childunblock() { sig_unblock(SIGCHLD); } -void sig_childcatch(f) void (*f)(); + +void sig_childcatch(void (*f)(int)) { sig_catch(SIGCHLD, f); } @@ -111,7 +113,8 @@ void sig_hangupunblock() { sig_unblock(SIGHUP); } -void sig_hangupcatch(f) void (*f)(); + +void sig_hangupcatch(void (*f)(int)) { sig_catch(SIGHUP, f); } @@ -132,7 +135,8 @@ void sig_termunblock() { sig_unblock(SIGTERM); } -void sig_termcatch(f) void (*f)(); + +void sig_termcatch(f) void (*f)(int); { sig_catch(SIGTERM, f); } @@ -144,7 +148,7 @@ void sig_termdefault() int sig_term = SIGTERM; -void sig_bugcatch(void (*f)()) +void sig_bugcatch(void (*f)(int)) { sig_catch(SIGILL, f); sig_catch(SIGABRT, f); @@ -159,7 +163,7 @@ void sig_bugcatch(void (*f)()) #endif } -void (*sig_defaulthandler)() = SIG_DFL; +void (*sig_defaulthandler)(int) = SIG_DFL; void sig_miscignore() { @@ -176,6 +180,6 @@ void sig_miscignore() #endif } -void (*sig_ignorehandler)() = SIG_IGN; +void (*sig_ignorehandler)(int) = SIG_IGN; int sig_cont = SIGCONT; |