Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/lib Pullup lib string format fixes [is].
details: https://anonhg.NetBSD.org/src/rev/e860dd4f6930
branches: netbsd-1-5
changeset: 489834:e860dd4f6930
user: tv <tv%NetBSD.org@localhost>
date: Tue Oct 17 22:33:54 2000 +0000
description:
Pullup lib string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
diffstat:
lib/Makefile.inc | 3 +-
lib/libc/time/private.h | 5 +-
lib/libpcap/bpf_image.c | 155 ++++++++++++++++++++---------------------------
lib/libpcap/optimize.c | 6 +-
4 files changed, 73 insertions(+), 96 deletions(-)
diffs (truncated from 383 to 300 lines):
diff -r da7a816d309e -r e860dd4f6930 lib/Makefile.inc
--- a/lib/Makefile.inc Tue Oct 17 22:07:00 2000 +0000
+++ b/lib/Makefile.inc Tue Oct 17 22:33:54 2000 +0000
@@ -1,3 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1 1997/10/09 14:36:17 lukem Exp $
+# $NetBSD: Makefile.inc,v 1.1.12.1 2000/10/17 22:33:54 tv Exp $
WARNS?= 1
+WFORMAT?= 2
diff -r da7a816d309e -r e860dd4f6930 lib/libc/time/private.h
--- a/lib/libc/time/private.h Tue Oct 17 22:07:00 2000 +0000
+++ b/lib/libc/time/private.h Tue Oct 17 22:33:54 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: private.h,v 1.14 1999/11/10 20:32:31 kleink Exp $ */
+/* $NetBSD: private.h,v 1.14.4.1 2000/10/17 22:33:55 tv Exp $ */
#ifndef PRIVATE_H
#define PRIVATE_H
@@ -210,7 +210,8 @@
void * irealloc P((void * pointer, int size));
void icfree P((char * pointer));
void ifree P((char * pointer));
-char * scheck P((const char *string, const char *format));
+char * scheck P((const char *string, const char *format))
+ __attribute__((__format_arg__(2)));
/*
diff -r da7a816d309e -r e860dd4f6930 lib/libpcap/bpf_image.c
--- a/lib/libpcap/bpf_image.c Tue Oct 17 22:07:00 2000 +0000
+++ b/lib/libpcap/bpf_image.c Tue Oct 17 22:33:54 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf_image.c,v 1.5 1997/10/03 15:53:02 christos Exp $ */
+/* $NetBSD: bpf_image.c,v 1.5.12.1 2000/10/17 22:33:55 tv Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1994, 1995, 1996
@@ -27,7 +27,7 @@
static const char rcsid[] =
"@(#) Header: bpf_image.c,v 1.22 96/09/26 23:27:56 leres Exp (LBL)";
#else
-__RCSID("$NetBSD: bpf_image.c,v 1.5 1997/10/03 15:53:02 christos Exp $");
+__RCSID("$NetBSD: bpf_image.c,v 1.5.12.1 2000/10/17 22:33:55 tv Exp $");
#endif
#endif
@@ -50,246 +50,221 @@
int n;
{
int v;
- char *fmt, *op;
+ char *op;
static char image[256];
char operand[64];
+ operand[0] = 0;
+
v = p->k;
switch (p->code) {
default:
op = "unimp";
- fmt = "0x%x";
- v = p->code;
+ snprintf(operand, sizeof operand, "0x%x", p->code);
break;
case BPF_RET|BPF_K:
op = "ret";
- fmt = "#%d";
- break;
+ goto immediate;
case BPF_RET|BPF_A:
op = "ret";
- fmt = "";
break;
case BPF_LD|BPF_W|BPF_ABS:
op = "ld";
- fmt = "[%d]";
+ abs:
+ snprintf(operand, sizeof operand, "[%d]", v);
break;
case BPF_LD|BPF_H|BPF_ABS:
op = "ldh";
- fmt = "[%d]";
- break;
+ goto abs;
case BPF_LD|BPF_B|BPF_ABS:
op = "ldb";
- fmt = "[%d]";
- break;
+ goto abs;
case BPF_LD|BPF_W|BPF_LEN:
op = "ld";
- fmt = "#pktlen";
+ strlcpy(operand, "#pktlen", sizeof(operand));
break;
case BPF_LD|BPF_W|BPF_IND:
op = "ld";
- fmt = "[x + %d]";
+ offset:
+ snprintf(operand, sizeof(operand), "[x + %d]", v);
break;
case BPF_LD|BPF_H|BPF_IND:
op = "ldh";
- fmt = "[x + %d]";
- break;
+ goto offset;
case BPF_LD|BPF_B|BPF_IND:
op = "ldb";
- fmt = "[x + %d]";
- break;
+ goto offset;
case BPF_LD|BPF_IMM:
op = "ld";
- fmt = "#0x%x";
- break;
+ goto immediate_hex;
case BPF_LDX|BPF_IMM:
op = "ldx";
- fmt = "#0x%x";
- break;
+ goto immediate_hex;
case BPF_LDX|BPF_MSH|BPF_B:
op = "ldxb";
- fmt = "4*([%d]&0xf)";
+ snprintf(operand, sizeof(operand), "4*([%d]&0xf)", v);
break;
case BPF_LD|BPF_MEM:
op = "ld";
- fmt = "M[%d]";
+ mem:
+ snprintf(operand, sizeof(operand), "M[%d]", v);
break;
case BPF_LDX|BPF_MEM:
op = "ldx";
- fmt = "M[%d]";
- break;
+ goto mem;
case BPF_ST:
op = "st";
- fmt = "M[%d]";
- break;
-
+ goto mem;
+
case BPF_STX:
op = "stx";
- fmt = "M[%d]";
- break;
-
+ goto mem;
+
case BPF_JMP|BPF_JA:
op = "ja";
- fmt = "%d";
- v = n + 1 + p->k;
+ snprintf(operand, sizeof(operand), "%d", n + 1 + p->k);
break;
case BPF_JMP|BPF_JGT|BPF_K:
op = "jgt";
- fmt = "#0x%x";
- break;
+ goto immediate_hex;
case BPF_JMP|BPF_JGE|BPF_K:
op = "jge";
- fmt = "#0x%x";
- break;
+ goto immediate_hex;
case BPF_JMP|BPF_JEQ|BPF_K:
op = "jeq";
- fmt = "#0x%x";
- break;
+ goto immediate_hex;
case BPF_JMP|BPF_JSET|BPF_K:
op = "jset";
- fmt = "#0x%x";
- break;
+ goto immediate_hex;
case BPF_JMP|BPF_JGT|BPF_X:
op = "jgt";
- fmt = "x";
+ x:
+ strlcpy(operand, "x", sizeof(operand));
break;
case BPF_JMP|BPF_JGE|BPF_X:
op = "jge";
- fmt = "x";
- break;
+ goto x;
case BPF_JMP|BPF_JEQ|BPF_X:
op = "jeq";
- fmt = "x";
- break;
-
+ goto x;
+
case BPF_JMP|BPF_JSET|BPF_X:
op = "jset";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_ADD|BPF_X:
op = "add";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_SUB|BPF_X:
op = "sub";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_MUL|BPF_X:
op = "mul";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_DIV|BPF_X:
op = "div";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_AND|BPF_X:
op = "and";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_OR|BPF_X:
op = "or";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_LSH|BPF_X:
op = "lsh";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_RSH|BPF_X:
op = "rsh";
- fmt = "x";
- break;
+ goto x;
case BPF_ALU|BPF_ADD|BPF_K:
op = "add";
- fmt = "#%d";
- break;
+ goto immediate;
case BPF_ALU|BPF_SUB|BPF_K:
op = "sub";
- fmt = "#%d";
- break;
+ goto immediate;
case BPF_ALU|BPF_MUL|BPF_K:
op = "mul";
- fmt = "#%d";
- break;
+ goto immediate;
case BPF_ALU|BPF_DIV|BPF_K:
op = "div";
- fmt = "#%d";
+ immediate:
+ snprintf(operand, sizeof operand, "#%d", v);
break;
case BPF_ALU|BPF_AND|BPF_K:
op = "and";
- fmt = "#0x%x";
Home |
Main Index |
Thread Index |
Old Index