Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2019, Joyent, Inc.
  14  */
  15 
  16 /*
  17  * merge CTF containers
  18  */
  19 
  20 #include <stdio.h>
  21 #include <libctf.h>
  22 #include <sys/stat.h>
  23 #include <sys/types.h>
  24 #include <fcntl.h>
  25 #include <errno.h>
  26 #include <strings.h>
  27 #include <assert.h>
  28 #include <unistd.h>
  29 #include <sys/fcntl.h>
  30 #include <stdlib.h>
  31 #include <libelf.h>
  32 #include <gelf.h>
  33 #include <sys/mman.h>
  34 #include <libgen.h>
  35 #include <stdarg.h>
  36 #include <limits.h>
  37 
  38 static char *g_progname;
  39 static char *g_unique;
  40 static char *g_outfile;
  41 static uint_t g_nctf;
  42 
  43 #define CTFMERGE_OK     0
  44 #define CTFMERGE_FATAL  1
  45 #define CTFMERGE_USAGE  2
  46 
  47 #define CTFMERGE_DEFAULT_NTHREADS       8
  48 #define CTFMERGE_ALTEXEC        "CTFMERGE_ALTEXEC"
  49 
  50 static void
  51 ctfmerge_fatal(const char *fmt, ...)
  52 {
  53         va_list ap;
  54 
  55         (void) fprintf(stderr, "%s: ", g_progname);
  56         va_start(ap, fmt);
  57         (void) vfprintf(stderr, fmt, ap);
  58         va_end(ap);
  59 
  60         if (g_outfile != NULL)
  61                 (void) unlink(g_outfile);
  62 
  63         exit(CTFMERGE_FATAL);
  64 }
  65 
  66 /*
  67  * We failed to find CTF for this file, check if it's OK. If we're not derived
  68  * from C, or we have the -m option, we let missing CTF pass.
  69  */
  70 static void


   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2019 Joyent, Inc.
  14  */
  15 
  16 /*
  17  * merge CTF containers
  18  */
  19 
  20 #include <stdio.h>
  21 #include <libctf.h>
  22 #include <sys/stat.h>
  23 #include <sys/types.h>
  24 #include <fcntl.h>
  25 #include <errno.h>
  26 #include <strings.h>
  27 #include <assert.h>
  28 #include <unistd.h>
  29 #include <sys/fcntl.h>
  30 #include <stdlib.h>
  31 #include <libelf.h>
  32 #include <gelf.h>
  33 #include <sys/mman.h>
  34 #include <libgen.h>
  35 #include <stdarg.h>
  36 #include <limits.h>
  37 
  38 static char *g_progname;
  39 static char *g_unique;
  40 static char *g_outfile;
  41 static uint_t g_nctf;
  42 
  43 #define CTFMERGE_OK     0
  44 #define CTFMERGE_FATAL  1
  45 #define CTFMERGE_USAGE  2
  46 
  47 #define CTFMERGE_DEFAULT_NTHREADS       8
  48 #define CTFMERGE_ALTEXEC        "CTFMERGE_ALTEXEC"
  49 
  50 static void __attribute__((__noreturn__))
  51 ctfmerge_fatal(const char *fmt, ...)
  52 {
  53         va_list ap;
  54 
  55         (void) fprintf(stderr, "%s: ", g_progname);
  56         va_start(ap, fmt);
  57         (void) vfprintf(stderr, fmt, ap);
  58         va_end(ap);
  59 
  60         if (g_outfile != NULL)
  61                 (void) unlink(g_outfile);
  62 
  63         exit(CTFMERGE_FATAL);
  64 }
  65 
  66 /*
  67  * We failed to find CTF for this file, check if it's OK. If we're not derived
  68  * from C, or we have the -m option, we let missing CTF pass.
  69  */
  70 static void