From nobody@FreeBSD.org  Mon Oct  7 21:17:01 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 37F4E37B404
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  7 Oct 2002 21:17:01 -0700 (PDT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D147743E86
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  7 Oct 2002 21:17:00 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.6/8.12.6) with ESMTP id g984H07R052541
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 7 Oct 2002 21:17:00 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.6/8.12.6/Submit) id g984H0O9052540;
	Mon, 7 Oct 2002 21:17:00 -0700 (PDT)
Message-Id: <200210080417.g984H0O9052540@www.freebsd.org>
Date: Mon, 7 Oct 2002 21:17:00 -0700 (PDT)
From: Tim Kientzle <kientzle@acm.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: 'sleep' is too big
X-Send-Pr-Version: www-1.0

>Number:         43811
>Category:       bin
>Synopsis:       'sleep' is too big
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    njl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 07 21:20:00 PDT 2002
>Closed-Date:    Sat Nov 23 16:11:00 PST 2002
>Last-Modified:  Sat Nov 23 16:11:00 PST 2002
>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:
State-Changed-From-To: open->closed 
State-Changed-By: njl 
State-Changed-When: Sat Nov 23 16:10:13 PST 2002 
State-Changed-Why:  
Committed patch to do essentially this.  sleep is now 19248 bytes.  More to 
come with atexit() fixes. 


Responsible-Changed-From-To: freebsd-bugs->njl 
Responsible-Changed-By: njl 
Responsible-Changed-When: Sat Nov 23 16:10:13 PST 2002 
Responsible-Changed-Why:  
I'm working with tim on this 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43811 
>Unformatted:
