Usermode/cat - Fixed order of fread/fwrite params
authorJohn Hodge <[email protected]>
Sun, 10 Feb 2013 01:43:36 +0000 (09:43 +0800)
committerJohn Hodge <[email protected]>
Sun, 10 Feb 2013 01:43:36 +0000 (09:43 +0800)
Usermode/Applications/cat_src/main.c

index 3fae4c6..45a8d1b 100644 (file)
@@ -12,7 +12,7 @@
  */
 int main(int argc, char *argv[])
 {
-        int    num;
+       size_t  num;
        char    buf[BUF_SIZE];
 
        if(argc < 2) {
@@ -27,9 +27,9 @@ int main(int argc, char *argv[])
        }
 
        do {
-               num = fread(buf, BUF_SIZE, 1, fp);
-               if(num < 0)     break;
-               fwrite(buf, num, 1, stdout);
+               num = fread(buf, 1, BUF_SIZE, fp);
+               if(num <= 0)    break;
+               fwrite(buf, 1, num, stdout);
        } while(num == BUF_SIZE);
 
        fclose(fp);

UCC git Repository :: git.ucc.asn.au