Print this page
10143 smatch fix for ttymon

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ttymon/tmhandler.c
          +++ new/usr/src/cmd/ttymon/tmhandler.c
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27   27  /*        All Rights Reserved   */
       28 +/*
       29 + * Copyright (c) 2018, Joyent, Inc.
       30 + */
  28   31  
  29   32  
  30      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  31      -
  32      -
  33   33  #include <stdlib.h>
  34   34  #include <stdio.h>
  35   35  #include <fcntl.h>
  36   36  #include <errno.h>
  37   37  #include <poll.h>
  38   38  #include <string.h>
  39   39  #include <termio.h>
  40   40  #include <signal.h>
  41   41  #include <sys/types.h>
  42   42  #include <sys/stropts.h>
↓ open down ↓ 583 lines elided ↑ open up ↑
 626  626  }
 627  627  
 628  628  /*
 629  629   * pcsync_close -  For the child process close all open fd's except
 630  630   * the one that is passed to the routine. Coordinate the reads and
 631  631   * writes to the pipes by the parent and child process to ensure
 632  632   * the parent and child processes have closed all the file descriptors
 633  633   * that are not needed any more.
 634  634   */
 635  635  static void
 636      -pcsync_close(p0, p1, pid, fd)
 637      -int     *p0;
 638      -int     *p1;
 639      -int     pid;
      636 +pcsync_close(int *p0, int *p1, int pid, int fd)
 640  637  {
 641  638          char    ch;
 642  639  
 643  640          if (pid == 0) {                         /* Child */
 644  641                  struct  pmtab   *tp;
 645  642                  for (tp = PMtab; tp; tp = tp->p_next)
 646  643                          if ((tp->p_fd > 0) && (tp->p_fd != fd))
 647  644                                  close(tp->p_fd);
 648  645                  close(p0[1]); close(p1[0]);
 649  646                  if (read(p0[0], &ch, 1) == 1)
 650  647                          write(p1[1], "a", 1);
 651  648                  close(p0[0]); close(p1[1]);
 652  649          } else {                                /* Parent */
 653  650                  close(p0[0]); close(p1[1]);
 654  651                  if (write(p0[1], "a", 1) == 1)
 655  652                          read(p1[0], &ch, 1);
 656  653                  close(p0[1]); close(p1[0]);
 657  654          }
 658  655  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX