From 6d0cfd4b044a0e8294d27921cef9a10ce2cbaa7a Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Mon, 7 Feb 2011 23:11:39 +0100 Subject: com32: single instance of skipspace() no need to keep several versions of it. --- com32/lib/pci/scan.c | 10 +--------- com32/lib/vsscanf.c | 7 ------- 2 files changed, 1 insertion(+), 16 deletions(-) (limited to 'com32/lib') diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c index 2577b321..c8334b11 100644 --- a/com32/lib/pci/scan.c +++ b/com32/lib/pci/scan.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #ifdef DEBUG @@ -49,15 +50,6 @@ #define MAX_LINE 512 -/* searching the next char that is not a space */ -static char *skipspace(char *p) -{ - while (*p && *p <= ' ') - p++; - - return p; -} - /* removing any \n found in a string */ static void remove_eol(char *string) { diff --git a/com32/lib/vsscanf.c b/com32/lib/vsscanf.c index d9fec51c..9a462c6a 100644 --- a/com32/lib/vsscanf.c +++ b/com32/lib/vsscanf.c @@ -47,13 +47,6 @@ enum bail { bail_err /* Conversion mismatch */ }; -static const char *skipspace(const char *p) -{ - while (isspace((unsigned char)*p)) - p++; - return p; -} - int vsscanf(const char *buffer, const char *format, va_list ap) { const char *p = format; -- cgit v1.2.1 From e86bdcd32ceb8550d0b1e59b73fb0ee243f3edad Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 19:54:20 -0500 Subject: com32: Move suffix_number() from libutil to libcom32 --- com32/lib/Makefile | 2 ++ com32/lib/suffix_number.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 com32/lib/suffix_number.c (limited to 'com32/lib') diff --git a/com32/lib/Makefile b/com32/lib/Makefile index 2035df22..754c8c33 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -32,6 +32,8 @@ LIBOBJS = \ \ dprintf.o vdprintf.o \ \ + suffix_number.o \ + \ sys/readdir.o getcwd.o chdir.o fdopendir.o \ \ libgcc/__ashldi3.o libgcc/__udivdi3.o \ diff --git a/com32/lib/suffix_number.c b/com32/lib/suffix_number.c new file mode 100644 index 00000000..49217f74 --- /dev/null +++ b/com32/lib/suffix_number.c @@ -0,0 +1,71 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2007-2009 H. Peter Anvin - All Rights Reserved + * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- */ + +/* + * suffix_number.c + * + * Convert a string of a number with potential SI suffix to int-type + */ + +#include + +/* Get a value with a potential suffix (k/m/g/t/p/e) */ +unsigned long long suffix_number(const char *str) +{ + char *ep; + unsigned long long v; + int shift; + + v = strtoull(str, &ep, 0); + switch (*ep | 0x20) { + case 'k': + shift = 10; + break; + case 'm': + shift = 20; + break; + case 'g': + shift = 30; + break; + case 't': + shift = 40; + break; + case 'p': + shift = 50; + break; + case 'e': + shift = 60; + break; + default: + shift = 0; + break; + } + v <<= shift; + + return v; +} -- cgit v1.2.1 From 6d63144949d795320bb7f70a6156b46615864f5f Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 20:07:43 -0500 Subject: memdisk & libcom32: Fix minor errors in previous commit --- com32/lib/syslinux/load_linux.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) (limited to 'com32/lib') diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c index df793625..3ac6e5d0 100644 --- a/com32/lib/syslinux/load_linux.c +++ b/com32/lib/syslinux/load_linux.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -96,42 +97,6 @@ struct linux_header { #define LOAD_HIGH 0x01 #define CAN_USE_HEAP 0x80 -/* Get a value with a potential suffix (k/m/g/t/p/e) */ -static unsigned long long suffix_number(const char *str) -{ - char *ep; - unsigned long long v; - int shift; - - v = strtoull(str, &ep, 0); - switch (*ep | 0x20) { - case 'k': - shift = 10; - break; - case 'm': - shift = 20; - break; - case 'g': - shift = 30; - break; - case 't': - shift = 40; - break; - case 'p': - shift = 50; - break; - case 'e': - shift = 60; - break; - default: - shift = 0; - break; - } - v <<= shift; - - return v; -} - /* * Find the last instance of a particular command line argument * (which should include the final =; do not use for boolean arguments) -- cgit v1.2.1 From 282527de6f2e3cce635b69c9ad13ffdbe98700a3 Mon Sep 17 00:00:00 2001 From: Gene Cumm Date: Tue, 8 Feb 2011 20:59:35 -0500 Subject: libcom32: Add header to suffix_number.c In case we ever define anything in the header --- com32/lib/suffix_number.c | 1 + 1 file changed, 1 insertion(+) (limited to 'com32/lib') diff --git a/com32/lib/suffix_number.c b/com32/lib/suffix_number.c index 49217f74..df073a00 100644 --- a/com32/lib/suffix_number.c +++ b/com32/lib/suffix_number.c @@ -33,6 +33,7 @@ */ #include +#include /* Get a value with a potential suffix (k/m/g/t/p/e) */ unsigned long long suffix_number(const char *str) -- cgit v1.2.1 From b507068d4788084347aa3860743dcaa57e49136a Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 24 Feb 2011 16:13:11 -0800 Subject: skipspace: move out of line Move skipspace() out of line since it triggers inlining warnings. Signed-off-by: H. Peter Anvin --- com32/lib/Makefile | 1 + com32/lib/skipspace.c | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 com32/lib/skipspace.c (limited to 'com32/lib') diff --git a/com32/lib/Makefile b/com32/lib/Makefile index 2035df22..7bfc0dbf 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -27,6 +27,7 @@ LIBOBJS = \ strtoumax.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o \ asprintf.o vasprintf.o strlcpy.o strlcat.o \ vsscanf.o zalloc.o \ + skipspace.o \ \ lmalloc.o lstrdup.o \ \ diff --git a/com32/lib/skipspace.c b/com32/lib/skipspace.c new file mode 100644 index 00000000..5db26519 --- /dev/null +++ b/com32/lib/skipspace.c @@ -0,0 +1,8 @@ +#include + +char *skipspace(const char *p) +{ + while (isspace((unsigned char)*p)) + p++; + return (char *)p; +} -- cgit v1.2.1