Date: Mon, 7 Oct 2002 21:17:00 -0700 (PDT) From: Tim Kientzle <kientzle@acm.org> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/43811: 'sleep' is too big Message-ID: <200210080417.g984H0O9052540@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 43811 >Category: bin >Synopsis: 'sleep' is too big >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Oct 07 21:20:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Tim Kientzle >Release: FreeBSD-CURRENT >Organization: >Environment: >Description: Sleep uses getopt() and printf(), which add over 35k. Neither is needed. The following patch reduces /bin/sleep from 45k to just over 9k. >How-To-Repeat: ls -l /bin/sleep <gasp in amazement> >Fix: Following patch reduces /bin/sleep to just over 9k. Only functional difference: error message is worded differently if an invalid option is specified. *** sleep.c-original Mon Oct 7 21:12:24 2002 --- sleep.c Mon Oct 7 21:12:54 2002 *************** *** 47,53 **** #include <ctype.h> #include <limits.h> - #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> --- 47,52 ---- *************** *** 61,83 **** long l; int ch, neg; char *p; ! while ((ch = getopt(argc, argv, "")) != -1) ! switch(ch) { ! case '?': ! default: ! usage(); ! /* NOTREACHED */ ! } ! argc -= optind; ! argv += optind; ! if (argc != 1) { usage(); /* NOTREACHED */ } ! p = argv[0]; /* Skip over leading whitespaces. */ while (isspace((unsigned char)*p)) --- 60,83 ---- long l; int ch, neg; char *p; + char **pp; ! /* Abort if no seconds value specified */ if (argc != 1) { usage(); /* NOTREACHED */ } ! /* Abort if any options were given */ ! pp = argv; ! while( ++pp != NULL ) { ! if(**pp == '-') { ! usage(); ! /* NOTREACHED */ ! } ! } ! ! p = argv[1]; /* Skip over leading whitespaces. */ while (isspace((unsigned char)*p)) *************** *** 128,134 **** void usage(void) { ! ! (void)fprintf(stderr, "usage: sleep seconds\n"); exit(1); } --- 128,133 ---- void usage(void) { ! (void)write(2, "usage: sleep seconds\n",21); exit(1); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210080417.g984H0O9052540>