Print this page
3244 utmpd.c: fix uninitialized variable, ret_val and other gcc warnings

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/utmpd/utmpd.c
          +++ new/usr/src/cmd/utmpd/utmpd.c
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
       22 + * Copyright 2014 Shruti V Sampat <shrutisampat@gmail.com>
       23 + */
       24 +
       25 +/*
  22   26   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23   27   * Use is subject to license terms.
  24   28   */
  25   29  
  26   30  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  27   31  /*        All Rights Reserved   */
  28   32  
  29   33  /*
  30   34   * Portions of such source code were derived from Berkeley 4.3 BSD
  31   35   * under license from the Regents of the University of California.
↓ open down ↓ 138 lines elided ↑ open up ↑
 170  174  static void nonfatal();         /* Prints error message */
 171  175  static void print_tables();     /* Prints out internal tables for Debug */
 172  176  static int proc_is_alive(pid_t pid);    /* Check if a process is alive */
 173  177  static void warn_utmp(void);
 174  178  
 175  179  /*
 176  180   * main()  - Main does basic setup and calls wait_for_pids() to do the work
 177  181   */
 178  182  
 179  183  int
 180      -main(argc, argv)
 181      -        char **argv;
      184 +main(int argc, char *argv[])
 182  185  {
 183  186          char *defp;
 184  187          struct rlimit rlim;
 185  188          int i;
 186  189          time_t curtime, now;
 187  190  
 188  191          prog_name = argv[0];                    /* Save invocation name */
 189  192  
 190  193          if (getuid() != 0)  {
 191  194                  (void) fprintf(stderr,
 192      -                        "You must be root to run this program\n");
      195 +                    "You must be root to run this program\n");
 193  196                  fatal("You must be root to run this program");
 194  197          }
 195  198  
 196  199          if (argc > 1) {
 197  200                  if ((argc == 2 && (int)strlen(argv[1]) >= 2) &&
 198  201                      (argv[1][0] == '-' && argv[1][1] == 'd')) {
 199  202                          Debug = 1;
 200  203                  } else {
 201  204                          (void) fprintf(stderr,
 202      -                                "%s: Wrong number of arguments\n", prog_name);
      205 +                            "%s: Wrong number of arguments\n", prog_name);
 203  206                          (void) fprintf(stderr,
 204      -                                "Usage: %s [-debug]\n", prog_name);
      207 +                            "Usage: %s [-debug]\n", prog_name);
 205  208                          exit(2);
 206  209                  }
 207  210          }
 208  211  
 209  212          /*
 210  213           * Read defaults file for poll timeout
 211  214           */
 212  215          if (defopen(UTMP_DEFAULT) == 0) {
 213  216                  if ((defp = defread("SCAN_PERIOD=")) != NULL) {
 214  217                          Poll_timeout = atol(defp);
↓ open down ↓ 127 lines elided ↑ open up ↑
 342  345   * Wait_for_pids        - wait for the termination of a process in the table.
 343  346   *                        Returns 1 on normal exist, 0 on failure.
 344  347   */
 345  348  
 346  349  static int
 347  350  wait_for_pids()
 348  351  {
 349  352          register struct pollfd *pfd;
 350  353          register int i;
 351  354          pid_t pid;
 352      -        int ret_val;
      355 +        int ret_val = 0;
 353  356          int timeout;
 354  357          static time_t last_timeout  = 0;
 355  358          static int bad_error  = 0;      /* Count of POLL errors */
 356  359  
 357  360          /*
 358  361           * First time through we initialize last_timeout to now.
 359  362           */
 360  363          if (last_timeout == 0)
 361  364                  last_timeout = time(NULL);
 362  365  
↓ open down ↓ 720 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX