Ignore:
Timestamp:
2017-12-04T18:44:24Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bde5c04
Parents:
40feeac
Message:

vfs_read/write() should return error code separately from number of bytes transferred.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    r40feeac r8e3498b  
    7272static int cmp_files(const char *fn0, const char *fn1)
    7373{
    74         int rc = 0;
     74        int rc = EOK;
    7575        const char *fn[2] = {fn0, fn1};
    7676        int fd[2] = {-1, -1};
    7777        char buffer[2][CMP_BUFLEN];
    78         ssize_t offset[2];
     78        size_t offset[2];
    7979        aoff64_t pos[2] = {};
    8080
     
    9090        do {
    9191                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                        }
    10699                }
    107100
    108101                if (offset[0] != offset[1] ||
    109102                    memcmp(buffer[0], buffer[1], offset[0]) != 0) {
     103                        printf("Return 1\n");
    110104                        rc = 1;
    111105                        goto end;
     
    149143
    150144        rc = cmp_files(argv[optind], argv[optind + 1]);
    151         if (rc)
     145        if (rc != EOK)
    152146                return CMD_FAILURE;
    153147        else
Note: See TracChangeset for help on using the changeset viewer.