From owner-p4-projects@FreeBSD.ORG Tue Apr 18 18:06:44 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B9C1316A5D1; Tue, 18 Apr 2006 18:06:44 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7FB9216A5C9 for ; Tue, 18 Apr 2006 18:06:44 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4BA4F43D46 for ; Tue, 18 Apr 2006 18:06:44 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3II6ixs080289 for ; Tue, 18 Apr 2006 18:06:44 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3II6hJh080283 for perforce@freebsd.org; Tue, 18 Apr 2006 18:06:43 GMT (envelope-from imp@freebsd.org) Date: Tue, 18 Apr 2006 18:06:43 GMT Message-Id: <200604181806.k3II6hJh080283@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 95507 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Apr 2006 18:06:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=95507 Change 95507 by imp@imp_Speedy on 2006/04/18 18:06:37 Save 118 bytes by using a more sensible interface. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/loader_prompt.c#3 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/p_string.c#2 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/p_string.h#2 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/loader_prompt.c#3 (text+ko) ==== @@ -72,21 +72,18 @@ static unsigned BuildIP(void) { - unsigned p_ip_addr, p_tmp_val; + unsigned p_ip_addr; - p_ASCIIToDec(argv[1], &p_ip_addr); + p_ip_addr = p_ASCIIToDec(argv[1]); p_ip_addr <<= 8; - p_ASCIIToDec(argv[2], &p_tmp_val); - p_ip_addr |= p_tmp_val; + p_ip_addr |= p_ASCIIToDec(argv[2]); p_ip_addr <<= 8; - p_ASCIIToDec(argv[3], &p_tmp_val); - p_ip_addr |= p_tmp_val; + p_ip_addr |= p_ASCIIToDec(argv[3]); p_ip_addr <<= 8; - p_ASCIIToDec(argv[4], &p_tmp_val); - p_ip_addr |= p_tmp_val; + p_ip_addr |= p_ASCIIToDec(argv[4]); return (p_ip_addr); } ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/p_string.c#2 (text+ko) ==== @@ -143,15 +143,16 @@ * NULL-terminated. * .KB_C_FN_DEFINITION_END */ -void -p_ASCIIToDec(const char *buf, unsigned *value) +unsigned +p_ASCIIToDec(const char *buf) { + unsigned v = 0; - *value = 0; while (*buf) { - *value *= 10; - *value += (*buf++) - '0'; + v *= 10; + v += (*buf++) - '0'; } + return (v); } ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/p_string.h#2 (text+ko) ==== @@ -29,7 +29,7 @@ int p_strlen(const char *buffer); char *p_strcpy(char *to, const char *from); void p_ASCIIToHex(const char *buf, unsigned *value); -void p_ASCIIToDec(const char *buf, unsigned *value); +unsigned p_ASCIIToDec(const char *buf); void p_memcpy(char *to, const char *from, unsigned size); int p_memcmp(const char *to, const char *from, unsigned size); int p_strcmp(const char *to, const char *from);