From owner-cvs-all Sun Jul 22 18:37:51 2001 Delivered-To: cvs-all@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 3953E37B401; Sun, 22 Jul 2001 18:37:44 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.4/8.11.4) with ESMTP id f6N1bgI01259; Mon, 23 Jul 2001 02:37:42 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.4/8.11.4) with ESMTP id f6N1bfg13122; Mon, 23 Jul 2001 02:37:41 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200107230137.f6N1bfg13122@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: Assar Westerlund Cc: Brian Somers , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libutil ecalloc.c emalloc.3 emalloc.c erealloc.c estrdup.c Makefile libutil.h In-Reply-To: Message from Assar Westerlund of "23 Jul 2001 03:03:54 +0200." <5lhew4h2x1.fsf@assaris.sics.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 23 Jul 2001 02:37:41 +0100 From: Brian Somers Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > Brian Somers writes: > > What a bizarre idea. IMHO this is not necessary. Was this discussed > > somewhere ? > > Why is this bizarre? Is it better having these functions in lots of > different programs under different names? I sent a mail about this to > freebsd-audit@freebsd.org. This sort of function should be thrown out in a code review on the basis that it obfuscates the code. ptr = emalloc(n); will mean nothing to a regular C programmer (except that it's probably doing a malloc with some extra stuff). if ((ptr = malloc(n)) == NULL) errx(1, "malloc %lu failed", (unsigned long)n); will mean much more (hmm, I'll bet errx() exits, I wonder what the ``1'' is for?), and if ((ptr = malloc(n)) == NULL) { fprintf(stderr, "malloc %lu failed\n", (unsigned long)n); exit(1); } would actually be portable. Adding routines such as these to our libraries and then using them from our programs just makes it irritating when you try to build something on another OS -- not to mention obfuscating our code base. Of course I completely disagree with the err/errx/warn/warnx stuff too for exactly the same reasons -- having wanted to build things such as newsyslog to Solaris. And before we know it, calls to things like this start slipping into our libraries... that way lies ruin ! > /assar -- Brian http://www.freebsd-services.com/ Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message