1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Changeset 2109

Show
Ignore:
Timestamp:
11/07/11 22:04:10 (19 months ago)
Author:
kaiwang27
Message:

Style changes to nm(1):
* Removed a few empty lines.
* Removed a few unneeded assertions.
* Removed a inner declaration.
* Insert a missing break.
* Do not use sysexits(3) error codes, since that is no longer encouraged by style(9).
* Update the nm(1) test suite to catch up with the exit code changes.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/nm/nm.c

    r2076 r2109  
    320320 
    321321        return (strcmp(((const struct sym_entry *)l)->name, 
    322                 ((const struct sym_entry *)r)->name)); 
     322            ((const struct sym_entry *)r)->name)); 
    323323} 
    324324 
     
    441441                return (ELFTC_DEM_ARM); 
    442442        else 
    443                 errx(EX_USAGE, "unknown demangling style '%s'", opt); 
     443                errx(1, "unknown demangling style '%s'", opt); 
    444444 
    445445        /* NOTREACHED */ 
     
    487487                        default: 
    488488                                warnx("%s: Invalid format", optarg); 
    489                                 usage(EX_USAGE); 
     489                                usage(1); 
    490490                        } 
    491491 
     
    540540                        default: 
    541541                                warnx("%s: Invalid radix", optarg); 
    542                                 usage(EX_USAGE); 
     542                                usage(1); 
    543543                        } 
    544544                        break; 
     
    569569                        break; 
    570570                case 'h': 
    571                         usage(EX_OK); 
     571                        usage(0); 
    572572                default : 
    573                         usage(EX_USAGE); 
     573                        usage(1); 
    574574                } 
    575575        } 
     
    585585        if (nm_opts.undef_only == true) { 
    586586                if (nm_opts.sort_fn == &cmp_size) 
    587                         errx(EX_USAGE, "--size-sort with -u is meaningless"); 
    588  
     587                        errx(1, "--size-sort with -u is meaningless"); 
    589588                if (nm_opts.def_only != 0) 
    590                         errx(EX_USAGE, 
    591                             "-u with --defined-only is meaningless"); 
     589                        errx(1, "-u with --defined-only is meaningless"); 
    592590        } 
    593591        if (nm_opts.print_debug == false) 
     
    616614        char type; 
    617615        bool filter; 
    618         int i; 
     616        int i, j; 
    619617 
    620618        assert(elf != NULL); 
     
    639637                data = NULL; 
    640638                while ((data = elf_getdata(scn, data)) != NULL) { 
    641                         int j = 1; 
     639                        j = 1; 
    642640                        while (gelf_getsym(data, j++, &sym) != NULL) { 
    643641 
     
    735733        nm_info.name = ELFTC_GETPROGNAME(); 
    736734        nm_info.def_filename = "a.out"; 
    737  
    738735        nm_opts.print_symbol = PRINT_SYM_SYM; 
    739736        nm_opts.print_name = PRINT_NAME_NONE; 
     
    742739        nm_opts.print_armap = false; 
    743740        nm_opts.print_size = 0; 
    744  
    745741        nm_opts.debug_line = false; 
    746  
    747742        nm_opts.def_only = 0; 
    748743        nm_opts.undef_only = false; 
    749  
    750744        nm_opts.sort_size = 0; 
    751745        nm_opts.sort_reverse = false; 
    752746        nm_opts.no_demangle = 0; 
    753  
    754747        nm_opts.sort_fn = &cmp_name; 
    755748        nm_opts.elem_print_fn = &sym_elem_print_all; 
    756749        nm_opts.value_print_fn = &sym_value_dec_print; 
    757750        nm_opts.size_print_fn = &sym_size_dec_print; 
    758  
    759751        SLIST_INIT(&nm_out_filter); 
    760752} 
     
    908900print_version(void) 
    909901{ 
     902 
    910903        (void) printf("%s (%s)\n", nm_info.name, elftc_version()); 
    911         exit(EX_OK); 
     904        exit(0); 
    912905} 
    913906 
     
    18701863                sec = "*LOPROC*"; 
    18711864                break; 
    1872  
    18731865        case SHN_HIPROC: 
    18741866                sec = "*HIPROC*"; 
    18751867                break; 
    1876  
    18771868        case SHN_LOOS: 
    18781869                sec = "*LOOS*"; 
    18791870                break; 
    1880  
    18811871        case SHN_HIOS: 
    18821872                sec = "*HIOS*"; 
    18831873                break; 
    1884  
    18851874        case SHN_ABS: 
    18861875                sec = "*ABS*"; 
    18871876                break; 
    1888  
    18891877        case SHN_COMMON: 
    18901878                sec = "*COM*"; 
    18911879                break; 
    1892  
    18931880        case SHN_HIRESERVE: 
    18941881                /* HIRESERVE or XINDEX */ 
    18951882                sec = "*HIRESERVE*"; 
    18961883                break; 
    1897  
    18981884        default: 
    18991885                if (ep->sym->st_shndx > p->sh_num) 
    19001886                        return; 
    19011887                sec = p->s_table[ep->sym->st_shndx]; 
     1888                break; 
    19021889        }; 
    19031890 
     
    19481935 
    19491936        assert(sym != NULL && "sym is null"); 
    1950  
    19511937        printf("%016" PRIo64, sym->st_size); 
    19521938} 
     
    19571943 
    19581944        assert(sym != NULL && "sym is null"); 
    1959  
    19601945        if (nm_elfclass == ELFCLASS32) 
    19611946                printf("%08" PRIx64, sym->st_size); 
     
    19691954 
    19701955        assert(sym != NULL && "sym is null"); 
    1971  
    19721956        printf("%016" PRId64, sym->st_size); 
    19731957} 
     
    19781962 
    19791963        assert(sym != NULL && "sym is null"); 
    1980  
    19811964        printf("%016" PRIo64, sym->st_value); 
    19821965} 
     
    19871970 
    19881971        assert(sym != NULL && "sym is null"); 
    1989  
    19901972        if (nm_elfclass == ELFCLASS32) 
    19911973                printf("%08" PRIx64, sym->st_value); 
     
    19991981 
    20001982        assert(sym != NULL && "sym is null"); 
    2001  
    20021983        printf("%016" PRId64, sym->st_value); 
    20031984} 
     
    20672048main(int argc, char **argv) 
    20682049{ 
    2069         int rtn = 1; 
    2070  
    2071         assert(argc > 0); 
     2050        int rtn; 
    20722051 
    20732052        global_init(); 
    2074  
    2075         assert(nm_info.name != NULL && "nm_info.name is null"); 
    2076         assert(nm_info.def_filename != NULL && "nm_info.def_filename is null"); 
    2077  
    20782053        get_opt(argc, argv); 
    2079  
    2080         assert(nm_opts.sort_fn != NULL && "nm_opts.sort_fn is null"); 
    2081         assert(nm_opts.elem_print_fn != NULL && 
    2082             "nm_opts.elem_print_fn is null"); 
    2083         assert(nm_opts.value_print_fn != NULL && 
    2084             "nm_opts.value_print_fn is null"); 
    2085  
    20862054        rtn = read_files(argc - optind, argv + optind); 
    2087  
    20882055        global_dest(); 
    20892056 
    2090         return (rtn); 
    2091 } 
     2057        exit(rtn); 
     2058} 
  • trunk/test/nm/ts/nm_option/tc.sh

    r2085 r2109  
    3939 
    4040ERROR_OK="0" 
    41 ERROR_USAGE="64" 
     41ERROR_USAGE="1" 
    4242 
    4343tet_startup=""