Changeset 132ab5d1 in mainline for uspace/app/taskdump/elf_core.c


Ignore:
Timestamp:
2018-01-30T03:20:45Z (8 years ago)
Author:
Jenda <jenda.jzqk73@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5a6cc679
Parents:
8bfb163 (diff), 6a5d05b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge commit '6a5d05bd2551e64111bea4f9332dd7448c26ce84' into forwardport

Separate return value from error code in gen_irq_code*().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskdump/elf_core.c

    r8bfb163 r132ab5d1  
    5555#include <stddef.h>
    5656#include <errno.h>
     57#include <str_error.h>
    5758#include <mem.h>
    5859#include <as.h>
     
    9798
    9899        int fd;
    99         ssize_t rc;
     100        int rc;
     101        size_t nwr;
    100102        unsigned int i;
    101103
     
    122124        }
    123125
    124         fd = vfs_lookup_open(file_name, WALK_REGULAR | WALK_MAY_CREATE,
    125             MODE_WRITE);
    126         if (fd < 0) {
    127                 printf("Failed opening file.\n");
     126        rc = vfs_lookup_open(file_name, WALK_REGULAR | WALK_MAY_CREATE,
     127            MODE_WRITE, &fd);
     128        if (rc != EOK) {
     129                printf("Failed opening file '%s': %s.\n", file_name, str_error(rc));
    128130                free(p_hdr);
    129131                return ENOENT;
     
    206208        }
    207209
    208         rc = vfs_write(fd, &pos, &elf_hdr, sizeof(elf_hdr));
    209         if (rc != sizeof(elf_hdr)) {
     210        rc = vfs_write(fd, &pos, &elf_hdr, sizeof(elf_hdr), &nwr);
     211        if (rc != EOK) {
    210212                printf("Failed writing ELF header.\n");
    211213                free(p_hdr);
     
    214216
    215217        for (i = 0; i < n_ph; ++i) {
    216                 rc = vfs_write(fd, &pos, &p_hdr[i], sizeof(p_hdr[i]));
    217                 if (rc != sizeof(p_hdr[i])) {
     218                rc = vfs_write(fd, &pos, &p_hdr[i], sizeof(p_hdr[i]), &nwr);
     219                if (rc != EOK) {
    218220                        printf("Failed writing program header.\n");
    219221                        free(p_hdr);
     
    231233        note.type = NT_PRSTATUS;
    232234
    233         rc = vfs_write(fd, &pos, &note, sizeof(elf_note_t));
    234         if (rc != sizeof(elf_note_t)) {
     235        rc = vfs_write(fd, &pos, &note, sizeof(elf_note_t), &nwr);
     236        if (rc != EOK) {
    235237                printf("Failed writing note header.\n");
    236238                free(p_hdr);
     
    238240        }
    239241
    240         rc = vfs_write(fd, &pos, "CORE", note.namesz);
    241         if (rc != (ssize_t) note.namesz) {
     242        rc = vfs_write(fd, &pos, "CORE", note.namesz, &nwr);
     243        if (rc != EOK) {
    242244                printf("Failed writing note header.\n");
    243245                free(p_hdr);
     
    247249        pos = ALIGN_UP(pos, word_size);
    248250
    249         rc = vfs_write(fd, &pos, &pr_status, sizeof(elf_prstatus_t));
    250         if (rc != sizeof(elf_prstatus_t)) {
     251        rc = vfs_write(fd, &pos, &pr_status, sizeof(elf_prstatus_t), &nwr);
     252        if (rc != EOK) {
    251253                printf("Failed writing register data.\n");
    252254                free(p_hdr);
     
    296298        size_t total;
    297299        uintptr_t addr;
    298         ssize_t rc;
     300        int rc;
     301        size_t nwr;
    299302
    300303        addr = area->start_addr;
     
    304307                to_copy = min(area->size - total, BUFFER_SIZE);
    305308                rc = udebug_mem_read(sess, buffer, addr, to_copy);
    306                 if (rc < 0) {
     309                if (rc != EOK) {
    307310                        printf("Failed reading task memory.\n");
    308311                        return EIO;
    309312                }
    310313
    311                 rc = vfs_write(fd, pos, buffer, to_copy);
    312                 if (rc != (ssize_t) to_copy) {
     314                rc = vfs_write(fd, pos, buffer, to_copy, &nwr);
     315                if (rc != EOK) {
    313316                        printf("Failed writing memory contents.\n");
    314317                        return EIO;
Note: See TracChangeset for help on using the changeset viewer.