Skip to content
Permalink
Browse files

Cleanup btos()

Found by: michaelortmann
Patch by: michaelortmann
  • Loading branch information
michaelortmann authored and vanosg committed Nov 2, 2019
1 parent 4e9acaf commit 6002e19b2e835bbaa8b07d68ad4f75f87a22148f
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/cmds.c
@@ -3004,25 +3004,24 @@ static void cmd_traffic(struct userrec *u, int idx, char *par)
static char traffictxt[20];
static char *btos(unsigned long bytes)
{
char unit[10];
const char *unit;
float xbytes;

sprintf(unit, "Bytes");
xbytes = bytes;
if (xbytes > 1024.0) {
sprintf(unit, "KBytes");
unit = "KBytes";
xbytes = xbytes / 1024.0;
}
if (xbytes > 1024.0) {
sprintf(unit, "MBytes");
unit = "MBytes";
xbytes = xbytes / 1024.0;
}
if (xbytes > 1024.0) {
sprintf(unit, "GBytes");
unit = "GBytes";
xbytes = xbytes / 1024.0;
}
if (xbytes > 1024.0) {
sprintf(unit, "TBytes");
unit = "TBytes";
xbytes = xbytes / 1024.0;
}
if (bytes > 1024)

0 comments on commit 6002e19

Please sign in to comment.
You can’t perform that action at this time.