From owner-freebsd-arch@FreeBSD.ORG Thu Sep 16 22:51:39 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9768016A4CF for ; Thu, 16 Sep 2004 22:51:39 +0000 (GMT) Received: from nic.ach.sch.gr (nic.sch.gr [194.63.238.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9B95043D5A for ; Thu, 16 Sep 2004 22:51:38 +0000 (GMT) (envelope-from keramida@freebsd.org) Received: (qmail 19531 invoked by uid 207); 16 Sep 2004 22:51:37 -0000 Received: from keramida@freebsd.org by nic by uid 201 with qmail-scanner-1.21 (sophie: 3.04/2.19/3.81. Clear:RC:1(81.186.70.81):. Processed in 0.843526 secs); 16 Sep 2004 22:51:37 -0000 Received: from dialup81.ach.sch.gr (HELO gothmog.gr) ([81.186.70.81]) (envelope-sender ) by nic.sch.gr (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 16 Sep 2004 22:51:36 -0000 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id i8GMnTfM055867; Fri, 17 Sep 2004 01:49:29 +0300 (EEST) (envelope-from keramida@freebsd.org) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id i8GMnTNr055866; Fri, 17 Sep 2004 01:49:29 +0300 (EEST) (envelope-from keramida@freebsd.org) Date: Fri, 17 Sep 2004 01:49:29 +0300 From: Giorgos Keramidas To: Pawel Jakub Dawidek Message-ID: <20040916224929.GA50482@gothmog.gr> References: <20040916184201.GD30151@darkness.comp.waw.pl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="vtzGhvizbBRQ85DL" Content-Disposition: inline In-Reply-To: <20040916184201.GD30151@darkness.comp.waw.pl> Phone: +30-2610-312145 Mobile: +30-6944-116520 cc: freebsd-arch@freebsd.org Subject: Re: New libutil function: parse_capacity(3). X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2004 22:51:39 -0000 --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2004-09-16 20:42, Pawel Jakub Dawidek wrote: > http://people.freebsd.org/~pjd/patches/parse_capacity.patch > Any comments before committing? Is it intentional that it works even for "negative" capacities? : $ ./foo : -10 fffffffffffffff6 | -10 fffffffffffffff6 : -10240 ffffffffffffd800 | -10k ffffffffffffd800 --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="foo.c" #include #include struct data { off_t d_off; const char *d_str; }; static struct data v[] = { { -10, "-10" }, { -10 * 1024, "-10k" }, }; static const size_t vlen = sizeof(v) / sizeof(v[0]); extern off_t parse_capacity(const char *capacity); static void foo(const struct data *); static void foo(const struct data *dp) { off_t val; val = parse_capacity(dp->d_str); printf("%10lld %016llx | %10s %016llx\n", dp->d_off, dp->d_off, dp->d_str, (unsigned long long)val); } int main(void) { size_t k; for (k = 0; k < vlen; k++) foo(v + k); return 0; } --vtzGhvizbBRQ85DL--