From 23309c9e22b3315ceb7bc92d60101a6c36fec18a Mon Sep 17 00:00:00 2001 From: thorpej Date: Wed, 30 Sep 1998 18:51:13 +0000 Subject: [PATCH] Make the magic type field explicitly unsigned and fix comparisons of this value appropriately. Fixes warnings on systems where char is naturally unsigned. --- usr.bin/file/file.h | 6 +++--- usr.bin/file/print.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/usr.bin/file/file.h b/usr.bin/file/file.h index 80198d9bfb62..ac773843ef91 100644 --- a/usr.bin/file/file.h +++ b/usr.bin/file/file.h @@ -1,4 +1,4 @@ -/* $NetBSD: file.h,v 1.12 1998/09/20 15:27:16 christos Exp $ */ +/* $NetBSD: file.h,v 1.13 1998/09/30 18:51:13 thorpej Exp $ */ /* * file.h - definitions for file(1) program @@ -48,12 +48,12 @@ struct magic { #define ADD 4 /* if '>&' appears, */ short cont_level; /* level of ">" */ struct { - char type; /* byte short long */ + unsigned char type; /* byte short long */ int32 offset; /* offset from indirection */ } in; int32 offset; /* offset to magic number */ unsigned char reln; /* relation (0=eq, '>'=gt, etc) */ - char type; /* int, short, long or string. */ + unsigned char type; /* int, short, long or string. */ char vallen; /* length of string value, if any */ #define BYTE 1 #define SHORT 2 diff --git a/usr.bin/file/print.c b/usr.bin/file/print.c index 2c23c964fbe6..1139db83b274 100644 --- a/usr.bin/file/print.c +++ b/usr.bin/file/print.c @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.14 1998/09/20 15:27:16 christos Exp $ */ +/* $NetBSD: print.c,v 1.15 1998/09/30 18:51:13 thorpej Exp $ */ /* * print.c - debugging printout routines @@ -45,7 +45,7 @@ #if 0 FILE_RCSID("@(#)Id: print.c,v 1.26 1998/06/27 13:57:23 christos Exp ") #else -__RCSID("$NetBSD: print.c,v 1.14 1998/09/20 15:27:16 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.15 1998/09/30 18:51:13 thorpej Exp $"); #endif #endif /* lint */ @@ -65,15 +65,15 @@ struct magic *m; if (m->flag & INDIR) (void) fprintf(stderr, "(%s,%d),", - (m->in.type >= 0 && m->in.type < SZOF(typ)) ? - typ[(unsigned char) m->in.type] : - "*bad*", + /* Note: in.type is unsigned */ + (m->in.type < SZOF(typ)) ? + typ[m->in.type] : "*bad*", m->in.offset); (void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "", - (m->type >= 0 && m->type < SZOF(typ)) ? - typ[(unsigned char) m->type] : - "*bad*"); + /* Note: type is unsigned */ + (m->type < SZOF(typ)) ? + typ[(unsigned char) m->type] : "*bad*"); if (m->mask != ~((uint32)0)) (void) fprintf(stderr, " & %.8x", m->mask);