From 1855dcd4d2560ee6a85ee271e81ba19d567dd596 Mon Sep 17 00:00:00 2001 From: dholland Date: Mon, 28 Jan 2008 02:37:50 +0000 Subject: Work around gcc signedness warning: if you check for uid_t < 0, gcc warns because it's unsigned, but I don't really want to rely on uid_t being unsigned on every platform this code might propagate to. --- canfield/cfscores/cfscores.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'canfield') diff --git a/canfield/cfscores/cfscores.c b/canfield/cfscores/cfscores.c index 0e8bdff7..fe1f7767 100644 --- a/canfield/cfscores/cfscores.c +++ b/canfield/cfscores/cfscores.c @@ -1,4 +1,4 @@ -/* $NetBSD: cfscores.c,v 1.13 2005/07/01 16:50:55 jmc Exp $ */ +/* $NetBSD: cfscores.c,v 1.14 2008/01/28 02:37:50 dholland Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\ #if 0 static char sccsid[] = "@(#)cfscores.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: cfscores.c,v 1.13 2005/07/01 16:50:55 jmc Exp $"); +__RCSID("$NetBSD: cfscores.c,v 1.14 2008/01/28 02:37:50 dholland Exp $"); #endif #endif /* not lint */ @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) { struct passwd *pw; - int uid; + uid_t uid; /* Revoke setgid privileges */ setgid(getgid()); @@ -116,13 +116,16 @@ void printuser(const struct passwd *pw, int printfail) { struct betinfo total; + off_t pos; int i; - if (pw->pw_uid < 0) { - printf("Bad uid %d\n", pw->pw_uid); + pos = pw->pw_uid * (off_t)sizeof(struct betinfo); + /* test pos, not pw_uid; uid_t can be unsigned, which makes gcc warn */ + if (pos < 0) { + printf("Bad uid %d\n", (int)pw->pw_uid); return; } - i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), SEEK_SET); + i = lseek(dbfd, pos, SEEK_SET); if (i < 0) warn("lseek %s", _PATH_SCORE); i = read(dbfd, (char *)&total, sizeof(total)); -- cgit v1.2.3-56-ge451