[hackers] [sbase] Simplyfing mknod. Good eye, Truls Becken. || David Galos

From: <git_AT_suckless.org>
Date: Wed, 03 Jul 2013 17:48:19 +0200

commit 3c5f2b240750b3226c8dee75c1b20785f9bb2f16
Author: David Galos <galosd83_AT_students.rowan.edu>
Date: Wed Jul 3 11:48:06 2013 -0400

    Simplyfing mknod. Good eye, Truls Becken.

diff --git a/mknod.c b/mknod.c
index beb2ab7..3f53b01 100644
--- a/mknod.c
+++ b/mknod.c
_AT_@ -17,12 +17,8 @@ int
 main(int argc, char **argv)
 {
         mode_t type, mode = 0644;
- mode_t types['u'+1];
         dev_t dev;
 
- types['u'] = types['c'] = S_IFCHR;
- types['b'] = S_IFBLK;
-
         ARGBEGIN {
         case 'm':
                 mode = estrtol(EARGF(usage()), 8);
_AT_@ -36,7 +32,7 @@ main(int argc, char **argv)
 
         if(strlen(argv[1]) != 1 || !strchr("ucb", argv[1][0]))
                 eprintf("mknod: '%s': invalid type
", argv[1]);
- type = types[(unsigned)argv[1][0]];
+ type = (argv[1][0] == 'b') ? S_IFBLK : S_IFCHR;
 
         dev = makedev(estrtol(argv[2], 0), estrtol(argv[3], 0));
 
Received on Wed Jul 03 2013 - 17:48:19 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 03 2013 - 18:00:16 CEST