]> granicus.if.org Git - strace/commitdiff
tests/sethostname.c: use errno2name
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 21:22:50 +0000 (21:22 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 21 Apr 2016 22:05:56 +0000 (22:05 +0000)
tests/sethostname.c

index 8d98cb6d625c5d0dc257599a36185453e04a57df..3e21d9fbe5f6c93e96a2dc2f76ae8e35f53d2a3f 100644 (file)
 int
 main(void)
 {
-       const char *hostname = NULL;
-       int rc = syscall(__NR_sethostname, hostname, 63);
-       const char *errno_text;
-       switch (errno) {
-               case ENOSYS:
-                       errno_text = "ENOSYS";
-                       break;
-               case EPERM:
-                       errno_text = "EPERM";
-                       break;
-               default:
-                       errno_text = "EFAULT";
-       }
-       printf("sethostname(NULL, %d) = %d %s (%m)\n",
-              63, rc, errno_text);
+       long rc = syscall(__NR_sethostname, 0, 63);
+       printf("sethostname(NULL, 63) = %ld %s (%m)\n",
+              rc, errno2name());
 
        puts("+++ exited with 0 +++");
        return 0;