Changeset 8e3498b in mainline for uspace/app/bdsh/cmds/modules/cmp/cmp.c
- Timestamp:
- 2017-12-04T18:44:24Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bde5c04
- Parents:
- 40feeac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cmp/cmp.c
r40feeac r8e3498b 72 72 static int cmp_files(const char *fn0, const char *fn1) 73 73 { 74 int rc = 0;74 int rc = EOK; 75 75 const char *fn[2] = {fn0, fn1}; 76 76 int fd[2] = {-1, -1}; 77 77 char buffer[2][CMP_BUFLEN]; 78 s size_t offset[2];78 size_t offset[2]; 79 79 aoff64_t pos[2] = {}; 80 80 … … 90 90 do { 91 91 for (int i = 0; i < 2; i++) { 92 offset[i] = 0; 93 ssize_t size; 94 do { 95 size = vfs_read(fd[i], &pos[i], 96 buffer[i] + offset[i], 97 CMP_BUFLEN - offset[i]); 98 if (size < 0) { 99 rc = size; 100 printf("Error reading from %s\n", 101 fn[i]); 102 goto end; 103 } 104 offset[i] += size; 105 } while (size && offset[i] < CMP_BUFLEN); 92 rc = vfs_read(fd[i], &pos[i], buffer[i], CMP_BUFLEN, 93 &offset[i]); 94 if (rc != EOK) { 95 printf("Error reading from %s\n", 96 fn[i]); 97 goto end; 98 } 106 99 } 107 100 108 101 if (offset[0] != offset[1] || 109 102 memcmp(buffer[0], buffer[1], offset[0]) != 0) { 103 printf("Return 1\n"); 110 104 rc = 1; 111 105 goto end; … … 149 143 150 144 rc = cmp_files(argv[optind], argv[optind + 1]); 151 if (rc )145 if (rc != EOK) 152 146 return CMD_FAILURE; 153 147 else
Note:
See TracChangeset
for help on using the changeset viewer.