Skip to content

Commit

Permalink
Changed nconv variable from long to int in /lib/bytes_by_prefix.c
Browse files Browse the repository at this point in the history
According to sscanf man page the return value is int
therefore the holding variable should be int as well.

Also changed the loop variable name of the main method
from ind to i in order to better represent that it is
just a loop variable.

Signed-off-by: Marios Makris <marios.makris@gmail.com>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
  • Loading branch information
mk-marioh authored and metan-ucw committed May 16, 2012
1 parent 1475f67 commit 3d3e94e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/bytes_by_prefix.c
Expand Up @@ -108,7 +108,7 @@ int bytes_by_prefix(char *s)
long lbytes_by_prefix(char *s)
{
char mult, junk;
long nconv;
int nconv;
float num;

nconv = sscanf(s, "%f%c%c", &num, &mult, &junk);
Expand Down Expand Up @@ -145,7 +145,7 @@ long lbytes_by_prefix(char *s)
long long llbytes_by_prefix(char *s)
{
char mult, junk;
long nconv;
int nconv;
double num;

nconv = sscanf(s, "%lf%c%c", &num, &mult, &junk);
Expand Down Expand Up @@ -179,23 +179,23 @@ long long llbytes_by_prefix(char *s)

main(int argc, char **argv)
{
int ind;
int i;

if (argc == 1) {
fprintf(stderr, "missing bytes_by_prefix() parameteres\n");
exit(1);
}

for (ind = 1; ind < argc; ind++) {
for (i = 1; i < argc; i++) {

printf("bytes_by_prefix(%s) returned %d\n",
argv[ind], bytes_by_prefix(argv[ind]));
argv[i], bytes_by_prefix(argv[i]));

printf("lbytes_by_prefix(%s) returned %ld\n",
argv[ind], lbytes_by_prefix(argv[ind]));
argv[i], lbytes_by_prefix(argv[i]));

printf("llbytes_by_prefix(%s) returned %lld\n",
argv[ind], llbytes_by_prefix(argv[ind]));
argv[i], llbytes_by_prefix(argv[i]));
}
}

Expand Down

0 comments on commit 3d3e94e

Please sign in to comment.