diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-07-12 18:37:31 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-07-12 18:37:31 +0000 |
commit | d0f3949724322ee8bfcd3f3026b6911ef764e498 (patch) | |
tree | d9ff086f51896678b67eb65c16c9da10743156ca /sys/netatalk/at_rmx.c | |
parent | de62cbb6ddc4c2fec11f84fb2727f2cac16f0d9a (diff) | |
download | FreeBSD-src-d0f3949724322ee8bfcd3f3026b6911ef764e498.zip FreeBSD-src-d0f3949724322ee8bfcd3f3026b6911ef764e498.tar.gz |
Imperfect synchronization solution to imperfect code: use a static 256
byte buffer in the stack for temporary printf results rather than a
global buffer without synchronization.
Diffstat (limited to 'sys/netatalk/at_rmx.c')
-rw-r--r-- | sys/netatalk/at_rmx.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/sys/netatalk/at_rmx.c b/sys/netatalk/at_rmx.c index ab03536..85e5797 100644 --- a/sys/netatalk/at_rmx.c +++ b/sys/netatalk/at_rmx.c @@ -40,10 +40,10 @@ int at_inithead(void **head, int off); -static char hexbuf[256]; +#define HEXBUF_LEN 256 -static char * -prsockaddr(void *v) +static const char * +prsockaddr(void *v, char *hexbuf) { char *bp = &hexbuf[0]; u_char *cp = v; @@ -55,7 +55,7 @@ prsockaddr(void *v) /* return: "(len) hexdump" */ bp += sprintf(bp, "(%d)", len); - for (cp++; cp < cplim && bp < hexbuf+252; cp++) { + for (cp++; cp < cplim && bp < hexbuf + (HEXBUF_LEN - 4); cp++) { *bp++ = "0123456789abcdef"[*cp / 16]; *bp++ = "0123456789abcdef"[*cp % 16]; } @@ -63,8 +63,7 @@ prsockaddr(void *v) bp+= sprintf(bp, "null"); } *bp = '\0'; - - return &hexbuf[0]; + return (hexbuf); } static struct radix_node * @@ -72,9 +71,10 @@ at_addroute(void *v_arg, void *n_arg, struct radix_node_head *head, struct radix_node *treenodes) { struct radix_node *rn; + char hexbuf[HEXBUF_LEN]; - printf("at_addroute: v=%s\n", prsockaddr(v_arg)); - printf("at_addroute: n=%s\n", prsockaddr(n_arg)); + printf("at_addroute: v=%s\n", prsockaddr(v_arg, hexbuf)); + printf("at_addroute: n=%s\n", prsockaddr(n_arg, hexbuf)); printf("at_addroute: head=%p treenodes=%p\n", (void *)head, (void *)treenodes); @@ -89,8 +89,9 @@ static struct radix_node * at_matroute(void *v_arg, struct radix_node_head *head) { struct radix_node *rn; + char hexbuf[HEXBUF_LEN]; - printf("at_matroute: v=%s\n", prsockaddr(v_arg)); + printf("at_matroute: v=%s\n", prsockaddr(v_arg, hexbuf)); printf("at_matroute: head=%p\n", (void *)head); rn = rn_match(v_arg, head); @@ -104,9 +105,10 @@ static struct radix_node * at_lookup(void *v_arg, void *m_arg, struct radix_node_head *head) { struct radix_node *rn; + char hexbuf[HEXBUF_LEN]; - printf("at_lookup: v=%s\n", prsockaddr(v_arg)); - printf("at_lookup: n=%s\n", prsockaddr(m_arg)); + printf("at_lookup: v=%s\n", prsockaddr(v_arg, hexbuf)); + printf("at_lookup: n=%s\n", prsockaddr(m_arg, hexbuf)); printf("at_lookup: head=%p\n", (void *)head); rn = rn_lookup(v_arg, m_arg, head); @@ -120,9 +122,10 @@ static struct radix_node * at_delroute(void *v_arg, void *netmask_arg, struct radix_node_head *head) { struct radix_node *rn; + char hexbuf[HEXBUF_LEN]; - printf("at_delroute: v=%s\n", prsockaddr(v_arg)); - printf("at_delroute: n=%s\n", prsockaddr(netmask_arg)); + printf("at_delroute: v=%s\n", prsockaddr(v_arg, hexbuf)); + printf("at_delroute: n=%s\n", prsockaddr(netmask_arg, hexbuf)); printf("at_delroute: head=%p\n", (void *)head); rn = rn_delete(v_arg, netmask_arg, head); |