rewrite to avoid division by zero
authorJim Bloom <bloom@ucbvax.Berkeley.EDU>
Tue, 5 Nov 1985 11:04:50 +0000 (03:04 -0800)
committerJim Bloom <bloom@ucbvax.Berkeley.EDU>
Tue, 5 Nov 1985 11:04:50 +0000 (03:04 -0800)
SCCS-vsn: usr.bin/quota/quota.c 5.3
SCCS-vsn: usr.sbin/repquota/repquota.c 5.3
SCCS-vsn: usr.sbin/edquota/edquota.c 5.3

usr/src/usr.bin/quota/quota.c
usr/src/usr.sbin/edquota/edquota.c
usr/src/usr.sbin/repquota/repquota.c

index 95c988e..0887b5b 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)quota.c    5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)quota.c    5.3 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -196,10 +196,10 @@ showquotas(uid, name)
                        heading(uid, name);
                        printf("%10s%8d%c%7d%8d%8s%8d%c%7d%8d%8s\n"
                                , fs->fs_file
                        heading(uid, name);
                        printf("%10s%8d%c%7d%8d%8s%8d%c%7d%8d%8s\n"
                                , fs->fs_file
-                               , (dqblk.dqb_curblocks / btodb(1024)) 
+                               , dbtob(dqblk.dqb_curblocks) / 1024
                                , (msgb == (char *)0) ? ' ' : '*'
                                , (msgb == (char *)0) ? ' ' : '*'
-                               , (dqblk.dqb_bsoftlimit / btodb(1024)) 
-                               , (dqblk.dqb_bhardlimit / btodb(1024)) 
+                               , dbtob(dqblk.dqb_bsoftlimit) / 1024
+                               , dbtob(dqblk.dqb_bhardlimit) / 1024
                                , dwarn
                                , dqblk.dqb_curinodes
                                , (msgi == (char *)0) ? ' ' : '*'
                                , dwarn
                                , dqblk.dqb_curinodes
                                , (msgi == (char *)0) ? ' ' : '*'
index 18bfb48..cdf1552 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)edquota.c  5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)edquota.c  5.3 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -173,8 +173,8 @@ getprivs(uid)
                fprintf(fd,
 "fs %s blocks (soft = %d, hard = %d) inodes (soft = %d, hard = %d)\n"
                        , dqf[i]
                fprintf(fd,
 "fs %s blocks (soft = %d, hard = %d) inodes (soft = %d, hard = %d)\n"
                        , dqf[i]
-                       , dq[i].dq_bsoftlimit / btodb(1024)
-                       , dq[i].dq_bhardlimit / btodb(1024)
+                       , dbtob(dq[i].dq_bsoftlimit) / 1024
+                       , dbtob(dq[i].dq_bhardlimit) / 1024
                        , dq[i].dq_isoftlimit
                        , dq[i].dq_ihardlimit
                );
                        , dq[i].dq_isoftlimit
                        , dq[i].dq_ihardlimit
                );
@@ -224,8 +224,8 @@ putprivs(uid)
                        fprintf(stderr, "%s: bad format\n", cp);
                        continue;
                }
                        fprintf(stderr, "%s: bad format\n", cp);
                        continue;
                }
-               dq[i].dq_bsoftlimit *= btodb(1024);
-               dq[i].dq_bhardlimit *= btodb(1024);
+               dq[i].dq_bsoftlimit = btodb(dq[i].dq_bsoftlimit * 1024);
+               dq[i].dq_bhardlimit = btodb(dq[i].dq_bhardlimit * 1024);
        }
        fclose(fd);
        n = i;
        }
        fclose(fd);
        n = i;
index 98e3486..ec632cb 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)repquota.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)repquota.c 5.3 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -166,9 +166,9 @@ repquota(fsdev, fsfile, qffile)
                        fup->fu_dqblk.dqb_isoftlimit &&
                            fup->fu_dqblk.dqb_curinodes >=
                            fup->fu_dqblk.dqb_isoftlimit ? '+' : '-',
                        fup->fu_dqblk.dqb_isoftlimit &&
                            fup->fu_dqblk.dqb_curinodes >=
                            fup->fu_dqblk.dqb_isoftlimit ? '+' : '-',
-                       fup->fu_dqblk.dqb_curblocks / btodb(1024),
-                       fup->fu_dqblk.dqb_bsoftlimit / btodb(1024),
-                       fup->fu_dqblk.dqb_bhardlimit / btodb(1024),
+                       dbtob(fup->fu_dqblk.dqb_curblocks) / 1024,
+                       dbtob(fup->fu_dqblk.dqb_bsoftlimit) / 1024,
+                       dbtob(fup->fu_dqblk.dqb_bhardlimit) / 1024,
                        fup->fu_dqblk.dqb_bwarn,
                        fup->fu_dqblk.dqb_curinodes,
                        fup->fu_dqblk.dqb_isoftlimit,
                        fup->fu_dqblk.dqb_bwarn,
                        fup->fu_dqblk.dqb_curinodes,
                        fup->fu_dqblk.dqb_isoftlimit,