Print this page
10130 smatch fixes for usr/src/cmd/fm


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 




  26 #include <sys/fm/protocol.h>
  27 #include <fm/fmd_snmp.h>
  28 #include <fm/fmd_msg.h>
  29 #include <fm/libfmevent.h>
  30 #include <net-snmp/net-snmp-config.h>
  31 #include <net-snmp/net-snmp-includes.h>
  32 #include <net-snmp/agent/net-snmp-agent-includes.h>
  33 #include <errno.h>
  34 #include <locale.h>
  35 #include <netdb.h>
  36 #include <signal.h>
  37 #include <strings.h>
  38 #include <stdlib.h>
  39 #include <unistd.h>
  40 #include <limits.h>
  41 #include <alloca.h>
  42 #include <priv_utils.h>
  43 #include <zone.h>
  44 #include "libfmnotify.h"
  45 


 560         get_svc_config();
 561 
 562         /*
 563          * In the case where we get started outside of SMF, args passed on the
 564          * command line override SMF property setting
 565          */
 566         while (optind < argc) {
 567                 while ((c = getopt(argc, argv, optstr)) != -1) {
 568                         switch (c) {
 569                         case 'd':
 570                                 nhdl->nh_debug = B_TRUE;
 571                                 break;
 572                         case 'f':
 573                                 run_fg = B_TRUE;
 574                                 break;
 575                         case 'R':
 576                                 nhdl->nh_rootdir = strdup(optarg);
 577                                 break;
 578                         default:
 579                                 free(nhdl);
 580                                 return (usage(nhdl->nh_pname));
 581                         }
 582                 }
 583         }
 584 
 585         /*
 586          * Set up a signal handler for SIGTERM (and SIGINT if we'll
 587          * be running in the foreground) to ensure sure we get a chance to exit
 588          * in an orderly fashion.  We also catch SIGHUP, which will be sent to
 589          * us by SMF if the service is refreshed.
 590          */
 591         (void) sigfillset(&set);
 592         (void) sigfillset(&act.sa_mask);
 593         act.sa_handler = nd_sighandler;
 594         act.sa_flags = 0;
 595 
 596         (void) sigaction(SIGTERM, &act, NULL);
 597         (void) sigdelset(&set, SIGTERM);
 598         (void) sigaction(SIGHUP, &act, NULL);
 599         (void) sigdelset(&set, SIGHUP);
 600 




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 #include <sys/fm/protocol.h>
  31 #include <fm/fmd_snmp.h>
  32 #include <fm/fmd_msg.h>
  33 #include <fm/libfmevent.h>
  34 #include <net-snmp/net-snmp-config.h>
  35 #include <net-snmp/net-snmp-includes.h>
  36 #include <net-snmp/agent/net-snmp-agent-includes.h>
  37 #include <errno.h>
  38 #include <locale.h>
  39 #include <netdb.h>
  40 #include <signal.h>
  41 #include <strings.h>
  42 #include <stdlib.h>
  43 #include <unistd.h>
  44 #include <limits.h>
  45 #include <alloca.h>
  46 #include <priv_utils.h>
  47 #include <zone.h>
  48 #include "libfmnotify.h"
  49 


 564         get_svc_config();
 565 
 566         /*
 567          * In the case where we get started outside of SMF, args passed on the
 568          * command line override SMF property setting
 569          */
 570         while (optind < argc) {
 571                 while ((c = getopt(argc, argv, optstr)) != -1) {
 572                         switch (c) {
 573                         case 'd':
 574                                 nhdl->nh_debug = B_TRUE;
 575                                 break;
 576                         case 'f':
 577                                 run_fg = B_TRUE;
 578                                 break;
 579                         case 'R':
 580                                 nhdl->nh_rootdir = strdup(optarg);
 581                                 break;
 582                         default:
 583                                 free(nhdl);
 584                                 return (usage(argv[0]));
 585                         }
 586                 }
 587         }
 588 
 589         /*
 590          * Set up a signal handler for SIGTERM (and SIGINT if we'll
 591          * be running in the foreground) to ensure sure we get a chance to exit
 592          * in an orderly fashion.  We also catch SIGHUP, which will be sent to
 593          * us by SMF if the service is refreshed.
 594          */
 595         (void) sigfillset(&set);
 596         (void) sigfillset(&act.sa_mask);
 597         act.sa_handler = nd_sighandler;
 598         act.sa_flags = 0;
 599 
 600         (void) sigaction(SIGTERM, &act, NULL);
 601         (void) sigdelset(&set, SIGTERM);
 602         (void) sigaction(SIGHUP, &act, NULL);
 603         (void) sigdelset(&set, SIGHUP);
 604