Changeset 6efd162 in mainline for uspace/drv/bus/isa/isa.c


Ignore:
Timestamp:
2015-04-05T07:50:32Z (9 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eb94d84
Parents:
c0393db
Message:

isa: partially revert the previous commit and replace read() with read_all().

As pointed out by Jakub, we already have a read_all() function in libc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/isa/isa.c

    rc0393db r6efd162  
    245245        bool opened = false;
    246246        int fd;
    247         size_t file_len;
    248         size_t total_read = 0;
     247        size_t len;
    249248        ssize_t r;
    250249
     
    257256        opened = true;
    258257
    259         file_len = lseek(fd, 0, SEEK_END);
     258        len = lseek(fd, 0, SEEK_END);
    260259        lseek(fd, 0, SEEK_SET);
    261         if (file_len == 0) {
     260        if (len == 0) {
    262261                ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.",
    263262                    conf_path);
     
    265264        }
    266265
    267         buf = malloc(file_len + 1);
     266        buf = malloc(len + 1);
    268267        if (buf == NULL) {
    269268                ddf_msg(LVL_ERROR, "Memory allocation failed.");
     
    271270        }
    272271
    273         do {
    274                 r = read(fd, &buf[total_read], file_len - total_read);
    275                 if (r < 0) {
    276                         ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
    277                         goto cleanup;
    278                 }
    279 
    280                 total_read += r;
    281         } while (total_read < file_len);
    282 
    283         buf[file_len] = 0;
     272        r = read_all(fd, buf, len);
     273        if (r < 0) {
     274                ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
     275                goto cleanup;
     276        }
     277
     278        buf[len] = 0;
    284279
    285280        suc = true;
Note: See TracChangeset for help on using the changeset viewer.