Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/lib/libc/net Pull up revision 1.19 (requested by is):
details: https://anonhg.NetBSD.org/src/rev/18db9cb4edd2
branches: netbsd-1-5
changeset: 489939:18db9cb4edd2
user: he <he%NetBSD.org@localhost>
date: Thu Oct 19 19:51:10 2000 +0000
description:
Pull up revision 1.19 (requested by is):
Construct format string at compile-time.
diffstat:
lib/libc/net/ethers.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diffs (44 lines):
diff -r 3deb07a493ba -r 18db9cb4edd2 lib/libc/net/ethers.c
--- a/lib/libc/net/ethers.c Thu Oct 19 19:49:33 2000 +0000
+++ b/lib/libc/net/ethers.c Thu Oct 19 19:51:10 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ethers.c,v 1.18 2000/04/24 10:40:24 itojun Exp $ */
+/* $NetBSD: ethers.c,v 1.18.4.1 2000/10/19 19:51:10 he Exp $ */
/*
* ethers(3N) a la Sun.
@@ -9,7 +9,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: ethers.c,v 1.18 2000/04/24 10:40:24 itojun Exp $");
+__RCSID("$NetBSD: ethers.c,v 1.18.4.1 2000/10/19 19:51:10 he Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -203,17 +203,19 @@
char *hostname;
{
u_int i[6];
- static char buf[sizeof " %x:%x:%x:%x:%x:%x %s\\n" + 21];
- /* XXX: 21 == strlen (ASCII representation of 2^64) */
+#define S2(arg) #arg
+#define S1(arg) S2(arg)
+ const static char fmt[] = " %x:%x:%x:%x:%x:%x"
+ " %" S1(MAXHOSTNAMELEN) "s\n";
+#undef S2
+#undef S1
+
_DIAGASSERT(l != NULL);
_DIAGASSERT(e != NULL);
_DIAGASSERT(hostname != NULL);
- if (! buf[0])
- snprintf(buf, sizeof buf, " %%x:%%x:%%x:%%x:%%x:%%x %%%ds\\n",
- MAXHOSTNAMELEN);
- if (sscanf(l, buf,
+ if (sscanf(l, fmt,
&i[0], &i[1], &i[2], &i[3], &i[4], &i[5], hostname) == 7) {
e->ether_addr_octet[0] = (u_char)i[0];
e->ether_addr_octet[1] = (u_char)i[1];
Home |
Main Index |
Thread Index |
Old Index