summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2006-11-27 15:26:26 +0000
committeryar <yar@FreeBSD.org>2006-11-27 15:26:26 +0000
commitb581495b16a0d6be96b25af8fb0a968263d8e306 (patch)
tree2c5acaceab6c460802f82fcd5938a59b584ba42e /usr.bin
parent00bb8d790bcfee45d110606ef46ce9930cb86ab8 (diff)
downloadFreeBSD-src-b581495b16a0d6be96b25af8fb0a968263d8e306.zip
FreeBSD-src-b581495b16a0d6be96b25af8fb0a968263d8e306.tar.gz
Allow for large scale factors. C99 warrants that
ULLONG_MAX is not less than 2^64-1; and uintmax_t cannot be more narrow than unsigned long long. This allows for scale factors up to Exa inclusively. Use plain int for the scale index to be consistent with ifcmds.c and enum.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/systat/convtbl.c10
-rw-r--r--usr.bin/systat/convtbl.h11
2 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/systat/convtbl.c b/usr.bin/systat/convtbl.c
index 2bfb922..7daf7d6 100644
--- a/usr.bin/systat/convtbl.c
+++ b/usr.bin/systat/convtbl.c
@@ -50,10 +50,10 @@ struct convtbl convtbl[] = {
static
struct convtbl *
-get_tbl_ptr(const u_long size, const u_int scale)
+get_tbl_ptr(const uintmax_t size, const int scale)
{
- u_long tmp;
- u_int idx;
+ uintmax_t tmp;
+ int idx;
/* If our index is out of range, default to auto-scaling. */
idx = scale < SC_AUTO ? scale : SC_AUTO;
@@ -73,7 +73,7 @@ get_tbl_ptr(const u_long size, const u_int scale)
}
double
-convert(const u_long size, const u_int scale)
+convert(const uintmax_t size, const int scale)
{
struct convtbl *tp;
@@ -83,7 +83,7 @@ convert(const u_long size, const u_int scale)
}
const char *
-get_string(const u_long size, const u_int scale)
+get_string(const uintmax_t size, const int scale)
{
struct convtbl *tp;
diff --git a/usr.bin/systat/convtbl.h b/usr.bin/systat/convtbl.h
index 4e459c6..e5cd702 100644
--- a/usr.bin/systat/convtbl.h
+++ b/usr.bin/systat/convtbl.h
@@ -32,10 +32,11 @@
#define _CONVTBL_H_
#include <sys/types.h>
+#include <stdint.h>
#define BITS (1)
#define BYTES (1)
-#define KILO (1024)
+#define KILO (1024LL)
#define MEGA (KILO * 1024)
#define GIGA (MEGA * 1024)
@@ -55,14 +56,14 @@ enum scale {
#define BYTE (1)
struct convtbl {
- u_int mul;
- u_int scale;
+ uintmax_t mul;
+ uintmax_t scale;
const char *str;
};
extern struct convtbl convtbl[];
-extern double convert(const u_long, const u_int);
-extern const char *get_string(const u_long, const u_int);
+extern double convert(const uintmax_t, const int);
+extern const char *get_string(const uintmax_t, const int);
#endif /* ! _CONVTBL_H_ */
OpenPOWER on IntegriCloud