[hackers] [ubase] Use estrtol() instead of atoi() || sin

From: <git_AT_suckless.org>
Date: Mon, 30 Jun 2014 17:57:26 +0200

commit 55dbbb7b3f726aa6fb836961f35d6128b6aa8adb
Author: sin <sin_AT_2f30.org>
Date: Mon Jun 30 16:50:29 2014 +0100

    Use estrtol() instead of atoi()
    
    Some more stylistic fixes.

diff --git a/chvt.c b/chvt.c
index b0087be..b73712c 100644
--- a/chvt.c
+++ b/chvt.c
_AT_@ -1,10 +1,11 @@
+/* See LICENSE file for copyright and license details. */
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
 #include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include "util.h"
 
 #define KDGKBTYPE 0x4B33 /* get keyboard type */
_AT_@ -32,25 +33,25 @@ main(int argc, char *argv[])
         int fd;
         char c;
 
- if(argc!=2 || strspn(argv[1], "1234567890") != strlen(argv[1]))
+ if (argc != 2 || strspn(argv[1], "1234567890") != strlen(argv[1]))
                 usage();
 
- n = atoi(argv[1]);
- for(i = 0; i < LEN(vts); i++) {
+ n = estrtol(argv[1], 10);
+ for (i = 0; i < LEN(vts); i++) {
                 fd = open(vts[i], O_RDONLY);
- if(fd < 1)
+ if (fd < 1)
                         continue;
                 c = 0;
- if(ioctl(fd, KDGKBTYPE, &c) == 0)
+ if (ioctl(fd, KDGKBTYPE, &c) == 0)
                         goto VTfound;
                 close(fd);
         }
 
         eprintf("couldn't find a console.
");
 VTfound:
- if(ioctl(fd, VT_ACTIVATE, n) == -1)
+ if (ioctl(fd, VT_ACTIVATE, n) == -1)
                 eprintf("VT_ACTIVATE %d:", n);
- if(ioctl(fd, VT_WAITACTIVE, n) == -1)
+ if (ioctl(fd, VT_WAITACTIVE, n) == -1)
                 eprintf("VT_WAITACTIVE %d:", n);
         close(fd);
 
Received on Mon Jun 30 2014 - 17:57:26 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 30 2014 - 18:00:10 CEST