Print this page
10126 smatch fix for kmfcfg


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   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  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  22  */
  23 




  24 #include <stdio.h>
  25 #include <strings.h>
  26 #include <ctype.h>
  27 #include <libgen.h>
  28 #include <libintl.h>
  29 #include <locale.h>
  30 
  31 #include <kmfapiP.h>
  32 
  33 #include "util.h"
  34 
  35 /*
  36  * The verbcmd construct allows genericizing information about a verb so
  37  * that it is easier to manipulate.  Makes parsing code easier to read,
  38  * fix, and extend with new verbs.
  39  */
  40 typedef struct verbcmd_s {
  41         char            *verb;
  42         int             (*action)(int, char *[]);
  43         char            *synopsis;


 172 kc_help()
 173 {
 174         usage();
 175         return (0);
 176 }
 177 
 178 int
 179 main(int argc, char *argv[])
 180 {
 181         int ret;
 182         int found;
 183         int i;
 184 
 185         (void) setlocale(LC_ALL, "");
 186 #if !defined(TEXT_DOMAIN)               /* Should be defined by cc -D. */
 187 #define TEXT_DOMAIN     "SYS_TEST"      /* Use this only if it isn't. */
 188 #endif
 189         (void) textdomain(TEXT_DOMAIN);
 190 
 191         prog = basename(argv[0]);
 192         argv++; argc--;

 193 
 194         if (argc == 0) {
 195                 usage();
 196                 exit(1);
 197         }
 198 
 199         if (argc == 1 && argv[0][0] == '-') {
 200                 switch (argv[0][1]) {
 201                         case '?':
 202                                 return (kc_help());
 203                         default:
 204                                 usage();
 205                                 exit(1);
 206                 }
 207         }
 208 
 209         found = -1;
 210         for (i = 0; i < num_cmds; i++) {
 211                 if (strcmp(cmds[i].verb, argv[0]) == 0) {
 212                         found = i;




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   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  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  22  */
  23 
  24 /*
  25  * Copyright (c) 2018, Joyent, Inc.
  26  */
  27 
  28 #include <stdio.h>
  29 #include <strings.h>
  30 #include <ctype.h>
  31 #include <libgen.h>
  32 #include <libintl.h>
  33 #include <locale.h>
  34 
  35 #include <kmfapiP.h>
  36 
  37 #include "util.h"
  38 
  39 /*
  40  * The verbcmd construct allows genericizing information about a verb so
  41  * that it is easier to manipulate.  Makes parsing code easier to read,
  42  * fix, and extend with new verbs.
  43  */
  44 typedef struct verbcmd_s {
  45         char            *verb;
  46         int             (*action)(int, char *[]);
  47         char            *synopsis;


 176 kc_help()
 177 {
 178         usage();
 179         return (0);
 180 }
 181 
 182 int
 183 main(int argc, char *argv[])
 184 {
 185         int ret;
 186         int found;
 187         int i;
 188 
 189         (void) setlocale(LC_ALL, "");
 190 #if !defined(TEXT_DOMAIN)               /* Should be defined by cc -D. */
 191 #define TEXT_DOMAIN     "SYS_TEST"      /* Use this only if it isn't. */
 192 #endif
 193         (void) textdomain(TEXT_DOMAIN);
 194 
 195         prog = basename(argv[0]);
 196         argv++;
 197         argc--;
 198 
 199         if (argc == 0) {
 200                 usage();
 201                 exit(1);
 202         }
 203 
 204         if (argc == 1 && argv[0][0] == '-') {
 205                 switch (argv[0][1]) {
 206                         case '?':
 207                                 return (kc_help());
 208                         default:
 209                                 usage();
 210                                 exit(1);
 211                 }
 212         }
 213 
 214         found = -1;
 215         for (i = 0; i < num_cmds; i++) {
 216                 if (strcmp(cmds[i].verb, argv[0]) == 0) {
 217                         found = i;