Print this page
Reduce lint

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/brand/lx/lx_init/lxinit.c
          +++ new/usr/src/lib/brand/lx/lx_init/lxinit.c
↓ open down ↓ 95 lines elided ↑ open up ↑
  96   96          va_end(ap);
  97   97  
  98   98          (void) write(1, PREFIX_LOG_ERR, strlen(PREFIX_LOG_ERR));
  99   99          (void) write(1, buf, len);
 100  100          (void) write(1, "\n", 1);
 101  101  
 102  102          /*
 103  103           * Since a non-zero exit will cause the zone to reboot, a pause here
 104  104           * will prevent a mis-configured zone from spinning in a reboot loop.
 105  105           */
 106      -        pause();
      106 +        (void) pause();
 107  107          exit(1);
 108  108          /*NOTREACHED*/
 109  109  }
 110  110  
 111  111  static void
 112  112  lxi_warn(char *msg, ...)
 113  113  {
 114  114          char buf[1024];
 115  115          int len;
 116  116          va_list ap;
↓ open down ↓ 80 lines elided ↑ open up ↑
 197  197                      MAXNAMELEN) == 0) {
 198  198                          *result = attrs->zone_res_attr_value;
 199  199                          return (0);
 200  200                  }
 201  201                  attrs = attrs->zone_res_attr_next;
 202  202          }
 203  203          return (-1);
 204  204  }
 205  205  #endif /* XXX KEBE SAYS NOT YET */
 206  206  
 207      -void
      207 +static void
 208  208  lxi_svc_start(char *name, char *path, char *fmri)
 209  209  {
 210  210          pid_t pid;
 211  211          int status;
 212      -        char *const argv[] = {
 213      -                name,
      212 +        char *argv[] = {
      213 +                NULL,
 214  214                  NULL
 215  215          };
 216      -        char *const envp[] = {
 217      -                fmri,
      216 +        char *envp[] = {
      217 +                NULL,
 218  218                  NULL
 219  219          };
      220 +        argv[0] = name;
      221 +        envp[0] = fmri;
 220  222  
 221  223          pid = fork();
 222  224          if (pid == -1) {
 223  225                  lxi_err("fork() failed: %s", strerror(errno));
 224  226          }
 225  227  
 226  228          if (pid == 0) {
 227  229                  /* child */
 228  230                  const char *zroot = zone_get_nroot();
 229  231                  char cmd[MAXPATHLEN];
 230  232  
 231  233                  /*
 232  234                   * Construct the full path to the binary, including the native
 233  235                   * system root (e.g. "/native") if in use for this zone:
 234  236                   */
 235  237                  (void) snprintf(cmd, sizeof (cmd), "%s%s", zroot != NULL ?
 236  238                      zroot : "", path);
 237  239  
 238      -                execve(cmd, argv, envp);
      240 +                (void) execve(cmd, argv, envp);
 239  241  
 240  242                  lxi_err("execve(%s) failed: %s", cmd, strerror(errno));
 241  243                  /* NOTREACHED */
 242  244          }
 243  245  
 244  246          /* parent */
 245      -        while (wait(&status) != pid) {
 246      -                /* EMPTY */;
 247      -        }
      247 +        while (wait(&status) != pid)
      248 +                ;
 248  249  
 249  250          if (WIFEXITED(status)) {
 250  251                  if (WEXITSTATUS(status) != 0) {
 251  252                          lxi_err("%s[%d] exited: %d", name,
 252  253                              (int)pid, WEXITSTATUS(status));
 253  254                  }
 254  255          } else if (WIFSIGNALED(status)) {
 255  256                  lxi_err("%s[%d] died on signal: %d", name,
 256  257                      (int)pid, WTERMSIG(status));
 257  258          } else {
↓ open down ↓ 233 lines elided ↑ open up ↑
 491  492  
 492  493          (void) close(s);
 493  494          return (0);
 494  495  }
 495  496  
 496  497  static int
 497  498  lxi_iface_gateway(const char *iface, const char *dst, int dstpfx,
 498  499      const char *gwaddr)
 499  500  {
 500  501          int idx, len, sockfd;
 501      -        char rtbuf[RTMBUFSZ];
      502 +        /* For lint-happy alignment, use a uint32_t array... */
      503 +        uint32_t rtbuf[RTMBUFSZ / sizeof (uint32_t)];
 502  504          struct rt_msghdr *rtm = (struct rt_msghdr *)rtbuf;
 503      -        struct sockaddr_in *dst_sin = (struct sockaddr_in *)
 504      -            (rtbuf + sizeof (struct rt_msghdr));
      505 +        struct sockaddr_in *dst_sin = (struct sockaddr_in *)(rtm + 1);
 505  506          struct sockaddr_in *gw_sin = (struct sockaddr_in *)(dst_sin + 1);
 506  507          struct sockaddr_in *netmask_sin = (struct sockaddr_in *)(gw_sin + 1);
 507  508  
 508  509          (void) bzero(rtm, RTMBUFSZ);
 509  510          rtm->rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
 510  511          rtm->rtm_flags = RTF_UP | RTF_STATIC | RTF_GATEWAY;
 511  512          rtm->rtm_msglen = sizeof (rtbuf);
 512  513          rtm->rtm_pid = getpid();
 513  514          rtm->rtm_type = RTM_ADD;
 514  515          rtm->rtm_version = RTM_VERSION;
↓ open down ↓ 31 lines elided ↑ open up ↑
 546  547                  rtm->rtm_index = idx;
 547  548          }
 548  549  
 549  550          if ((sockfd = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
 550  551                  lxi_warn("socket(PF_ROUTE): %s\n", strerror(errno));
 551  552                  return (-1);
 552  553          }
 553  554  
 554  555          if ((len = write(sockfd, rtbuf, rtm->rtm_msglen)) < 0) {
 555  556                  lxi_warn("could not write rtmsg: %s", strerror(errno));
 556      -                close(sockfd);
      557 +                (void) close(sockfd);
 557  558                  return (-1);
 558  559          } else if (len < rtm->rtm_msglen) {
 559  560                  lxi_warn("write() rtmsg incomplete");
 560      -                close(sockfd);
      561 +                (void) close(sockfd);
 561  562                  return (-1);
 562  563          }
 563  564  
 564      -        close(sockfd);
      565 +        (void) close(sockfd);
 565  566          return (0);
 566  567  }
 567  568  
 568  569  static void
 569  570  lxi_net_loopback()
 570  571  {
 571  572          const char *iface = "lo0";
 572  573          boolean_t first_ipv4_configured = B_FALSE;
 573  574  
 574  575          lxi_net_plumb(iface);
↓ open down ↓ 266 lines elided ↑ open up ↑
 841  842          int e;
 842  843  
 843  844          argv[0] = "init";
 844  845  
 845  846          /*
 846  847           * systemd uses the 'container' env var to determine it is running
 847  848           * inside a container. It only supports a few well-known types and
 848  849           * treats anything else as 'other' but this is enough to make it
 849  850           * behave better inside a zone. See 'detect_container' in systemd.
 850  851           */
 851      -        execve(cmd, argv, envp);
      852 +        (void) execve(cmd, argv, envp);
 852  853          e = errno;
 853  854  
 854  855          /*
 855  856           * Because stdout was closed prior to exec, it must be opened again in
 856  857           * the face of failure to log the error.
 857  858           */
 858  859          lxi_log_open();
 859  860          lxi_err("execve(%s) failed: %s", cmd, strerror(e));
 860  861  }
 861  862  
↓ open down ↓ 27 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX