]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - sys-utils/ipcrm.c
sys-utils: cleanup license lines, add SPDX
[thirdparty/util-linux.git] / sys-utils / ipcrm.c
index a9f2d1b9ada28723a7d0f61d3034eddd862ba923..d417c5593f44a5b4359b423d858b2ed40de831db 100644 (file)
@@ -1,14 +1,19 @@
 /*
- * krishna balasubramanian 1993
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Copyright (C) 1993 rishna balasubramanian
  *
  * 1999-02-22 Arkadiusz Miƛkiewicz <misiek@pld.ORG.PL>
  * - added Native Language Support
  *
  * 1999-04-02 frank zago
  * - can now remove several id's in the same call
- *
  */
-
 #include <errno.h>
 #include <getopt.h>
 #include <stdio.h>
@@ -65,8 +70,8 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(_(" -v, --verbose              explain what is being done\n"), out);
 
        fputs(USAGE_SEPARATOR, out);
-       printf(USAGE_HELP_OPTIONS(28));
-       printf(USAGE_MAN_TAIL("ipcrm(1)"));
+       fprintf(out, USAGE_HELP_OPTIONS(28));
+       fprintf(out, USAGE_MAN_TAIL("ipcrm(1)"));
 
        exit(EXIT_SUCCESS);
 }
@@ -125,12 +130,13 @@ static int remove_id(int type, int iskey, int id)
 static int remove_arg_list(type_id type, int argc, char **argv)
 {
        int id;
-       char *end;
+       char *end = NULL;
        int nb_errors = 0;
 
        do {
+               errno = 0;
                id = strtoul(argv[0], &end, 10);
-               if (*end != 0) {
+               if (errno || !end || *end != 0) {
                        warnx(_("invalid id: %s"), argv[0]);
                        nb_errors++;
                } else {
@@ -328,7 +334,7 @@ int main(int argc, char **argv)
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
-       atexit(close_stdout);
+       close_stdout_atexit();
 
        /* check to see if the command is being invoked in the old way if so
         * then remove argument list */
@@ -400,11 +406,11 @@ int main(int argc, char **argv)
                case 'v':
                        verbose = 1;
                        break;
+
                case 'h':
                        usage();
                case 'V':
-                       printf(UTIL_LINUX_VERSION);
-                       return EXIT_SUCCESS;
+                       print_version(EXIT_SUCCESS);
                default:
                        errtryhelp(EXIT_FAILURE);
                }