Date: Tue, 18 Apr 2006 18:06:43 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 95507 for review Message-ID: <200604181806.k3II6hJh080283@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604181806.k3II6hJh080283>