objdump: Remove switch() for binfmt - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 5d5161359e267f3f6dc4979fa46fe4a351acc884
 (DIR) parent a32be0f8efe59e3de6413b2bf2dc16c3db4ea2b5
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
       Date:   Mon, 27 Jan 2025 16:27:01 +0100
       
       objdump: Remove switch() for binfmt
       
       We can use the array and avoid duplicated information.
       
       Diffstat:
         M src/cmd/scc-objdump/main.c          |      13 +++++--------
       
       1 file changed, 5 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/scc-objdump/main.c b/src/cmd/scc-objdump/main.c
       @@ -255,6 +255,7 @@ errno_error:
        static void
        dumpobj(FILE *fp, int type, char *fmt)
        {
       +        int id;
                Obj *obj;
        
                printf("\n%s", filename);
       @@ -272,16 +273,12 @@ dumpobj(FILE *fp, int type, char *fmt)
                        goto err;
                }
        
       -        switch (objfmt(obj)) {
       -        case COFF32:
       -                op = &ops[COFF32];
       -                break;
       -        case ELF64:
       -                op = &ops[ELF64];
       -                break;
       -        default:
       +        id = objfmt(obj);
       +        if (id >= NFORMATS) {
                        error("unknown symbol binary format");
       +                return;
                }
       +        op = &ops[id];
        
                if (fflag)
                        dumpfhdr(obj, fmt);