New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 80883


Ignore:
Timestamp:
07/19/11 21:18:40 (4 years ago)
Author:
fotanus@…
Message:

cleanup C extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-post-destroot/base/src/pextlib1.0/macho.c

    r80618 r80883  
    99#include <sys/mman.h> 
    1010 
    11 #include <err.h> 
    1211#include <string.h> 
    1312 
     
    3029static const void *macho_read (macho_input_t *input, const void *address, size_t length) { 
    3130        if ((((uint8_t *) address) - ((uint8_t *) input->data)) + length > input->length) { 
    32                 warnx("Short read parsing Mach-O input"); 
    3331                return NULL; 
    3432        } 
     
    120118 
    121119                default: 
    122                         warnx("Unknown Mach-O magic: 0x%" PRIx32 "", *magic); 
    123                         return false; 
     120                        return TCL_ERROR; 
    124121        } 
    125122 
     
    158155        cmd = macho_offset(input, header, header_size, sizeof(struct load_command)); 
    159156        if (cmd == NULL) 
    160                 return false; 
     157                return TCL_ERROR; 
    161158        ncmds = swap32(header->ncmds); 
    162159 
     
    167164                cmd = macho_read(input, cmd, cmdsize); 
    168165                if (cmd == NULL) 
    169                         return false; 
     166                        return TCL_ERROR; 
    170167 
    171168                /* Handle known types */ 
     
    175172                                /* Fetch the path */ 
    176173                                if (cmdsize < sizeof(struct rpath_command)) { 
    177                                         warnx("Incorrect cmd size"); 
    178                                         return false; 
     174                                        return TCL_ERROR; 
    179175                                } 
    180176 
     
    182178                                const void *pathptr = macho_offset(input, cmd, sizeof(struct rpath_command), pathlen); 
    183179                                if (pathptr == NULL) 
    184                                         return false; 
     180                                        return TCL_ERROR; 
    185181 
    186182                                char *path = malloc(pathlen); 
     
    198194                                /* Extract the install name */ 
    199195                                if (cmdsize < sizeof(struct dylib_command)) { 
    200                                         warnx("Incorrect name size"); 
    201                                         return false; 
     196                                        return TCL_ERROR; 
    202197                                } 
    203198 
     
    205200                                const void *nameptr = macho_offset(input, cmd, sizeof(struct dylib_command), namelen); 
    206201                                if (nameptr == NULL) 
    207                                         return false; 
     202                                        return TCL_ERROR; 
    208203 
    209204                                char *name = malloc(namelen); 
     
    286281 
    287282                default: 
    288                         warnx("Unknown Mach-O magic: 0x%" PRIx32 "", *magic); 
    289283                        return TCL_ERROR; 
    290284        } 
     
    354348        void *data = mmap(NULL, stbuf.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); 
    355349        if (data == MAP_FAILED) 
    356                 err(1, "mmap()"); 
     350                return TCL_ERROR; 
    357351 
    358352        /* Parse */ 
     
    394388        void *data = mmap(NULL, stbuf.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); 
    395389        if (data == MAP_FAILED) 
    396                 err(1, "mmap()"); 
     390                return TCL_ERROR; 
    397391 
    398392        /* Parse */ 
Note: See TracChangeset for help on using the changeset viewer.