From 9cd7cb1bf19b3f186b4c8f6ca90aaa75f3310d7f Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Mon, 30 Dec 2013 06:19:42 +0000 Subject: [PATCH] Properly handle unsigned comparison. MFC after: 2 weeks --- sys/ufs/ufs/ufs_quota.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index a9498982432..f8bc981d5e5 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -307,7 +307,6 @@ int chkiq(struct inode *ip, int change, struct ucred *cred, int flags) { struct dquot *dq; - ino_t ncurinodes; int i, error, warn, do_check; #ifdef DIAGNOSTIC @@ -322,10 +321,8 @@ chkiq(struct inode *ip, int change, struct ucred *cred, int flags) continue; DQI_LOCK(dq); DQI_WAIT(dq, PINOD+1, "chkiq1"); - ncurinodes = dq->dq_curinodes + change; - /* XXX: ncurinodes is unsigned */ - if (dq->dq_curinodes != 0 && ncurinodes >= 0) - dq->dq_curinodes = ncurinodes; + if (dq->dq_curinodes >= -change) + dq->dq_curinodes += change; else dq->dq_curinodes = 0; dq->dq_flags &= ~DQ_INODS; @@ -359,11 +356,8 @@ chkiq(struct inode *ip, int change, struct ucred *cred, int flags) continue; DQI_LOCK(dq); DQI_WAIT(dq, PINOD+1, "chkiq3"); - ncurinodes = dq->dq_curinodes - change; - /* XXX: ncurinodes is unsigned */ - if (dq->dq_curinodes != 0 && - ncurinodes >= 0) - dq->dq_curinodes = ncurinodes; + if (dq->dq_curinodes >= change) + dq->dq_curinodes -= change; else dq->dq_curinodes = 0; dq->dq_flags &= ~DQ_INODS;