summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
Commit message (Collapse)AuthorAgeLines
* lib:vsprintf: reduce scope of pack_hex_byteJeroen Hofstee2014-07-18-11/+11
| | | | | | | | pack_hex_byte is only used when CONFIG_CMD_NET is defined so limit it to that scope. This prevents a clang warning. Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
* lib: fix return codes when CONFIG_SYS_VSNPRINTF is enabledDarwin Rambo2014-01-24-0/+1
| | | | | | | | | | | | When CONFIG_SYS_VSNPRINTF is enabled, it protects print operations such as sprintf, snprintf, vsnprintf, etc., from buffer overflows. But vsnprintf_internal includes the terminating NULL character in the calculation of number of characters written. This affects sprintf and snprintf return values. Fix this issue by setting pointer 'str' back to the location of the '\0'. Signed-off-by: Darwin Rambo <drambo@broadcom.com> Reviewed-by: Steve Rae <srae@broadcom.com>
* Add function to print a number with grouped digitsSimon Glass2013-06-26-0/+16
| | | | | | | Move bootstage's numbering printing code into a generic place so that it can be used by tracing also. Signed-off-by: Simon Glass <sjg@chromium.org>
* vsprintf: add ustrtoll functionPiotr Wilczek2013-02-19-0/+23
| | | | | | | | Add 'ustrtoull' function to convert size from string (ex: 1GiB) to unsigned long long type Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
* vsprintf:fix: Change type returned by ustrtoulLukasz Majewski2012-12-13-1/+1
| | | | | | | | | | | The ustrtoul shall convert string defined size (e.g. 1GiB) to unsigned long type (as its name implies). Up till now it had returned int, which might cause problems with large numbers (GiB range), when interpreted as U2 signed numbers. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
* lib/vsprintf.c: sparse fixesKim Phillips2012-11-04-2/+2
| | | | | | | vsprintf.c:31:12: warning: symbol 'hex_asc' was not declared. Should it be static? vsprintf.c:398:18: warning: Using plain integer as NULL pointer Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
* lib/vsprintf.c: don't special-case pointers to address nullWolfgang Denk2012-11-02-0/+6
| | | | | | | | | | | | | | The %p format of printf() would print a pointer to address null as "(null)". This makes sense in a real OS where a NULL pointer must never be dereferenced, but this is a bootloader, and there are cases where accessing the data at address null makes perfect sense. Remove the special case in lib/vsprintf.c using "#if 0" with a comment to make clear this was an intentional change and to stop re-adding this code. Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* lib: vsprintf.c: replace NUM_TYPE with s64/u64 typesDaniel Schwierzeck2012-10-15-6/+5
| | | | | | | | | | | This fixes warnings when compiling with ELDK-5.2.1 for MIPS64: vsprintf.c: In function 'put_dec': vsprintf.c:258:9: warning: comparison of distinct pointer types lacks a cast [enabled by default] vsprintf.c:258:3: warning: passing argument 1 of '__div64_32' from incompatible pointer type [enabled by default] include/div64.h:22:17: note: expected 'uint64_t *' but argument is of type 'long long unsigned int *' Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
* lib: vsprintf.c: fix checkpath.pl warningsDaniel Schwierzeck2012-10-15-50/+77
| | | | Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
* vsprintf: Move function documentation into header fileSimon Glass2011-12-17-100/+0
| | | | | | | Now that this is not in common.h, perhaps it is acceptable to move this documentation into the header file. Signed-off-by: Simon Glass <sjg@chromium.org>
* Add safe vsnprintf and snprintf library functionsSonny Rao2011-12-17-52/+213
| | | | | | | | | | | | | | | | From: Sonny Rao <sonnyrao@chromium.org> These functions are useful in U-Boot because they allow a graceful failure rather than an unpredictable stack overflow when printf() buffers are exceeded. Mostly copied from the Linux kernel. I copied vscnprintf and scnprintf so we can change printf and vprintf to use the safe implementation but still return the correct values. (Simon Glass <sjg@chromium.org> modified this commit a little) Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
* Move simple_itoa to vsprintfSimon Glass2011-10-26-0/+16
| | | | | | | This function is generally useful and shouldn't hide away in hush. It has been moved as is. Signed-off-by: Simon Glass <sjg@chromium.org>
* Add assert() for debug assertionsSimon Glass2011-09-10-0/+8
| | | | | | | | | | | | | | | assert() is like BUG_ON() but compiles to nothing unless DEBUG is defined. This is useful when a condition is an error but a board reset is unlikely to fix it, so it is better to soldier on in hope. Assertion failures should be caught during development/test. It turns out that assert() is defined separately in a few places in U-Boot with various meanings. This patch cleans up some of these. Build errors exposed by this change (and defining DEBUG) are also fixed in this patch. Signed-off-by: Simon Glass <sjg@chromium.org>
* panic: remove warning "'noreturn' function does return"Heiko Schocher2011-07-28-0/+2
| | | | | | | | | | | | | | | | | | | | since commit commit d2e8b911c0a0661d395ccac72156040702ac842d Author: Mike Frysinger <vapier@gentoo.org> Date: Wed Jun 29 11:58:04 2011 +0000 panic: add noreturn attribute I see the following warnings: vsprintf.c: In function 'panic': vsprintf.c:730: warning: 'noreturn' function does return for nearly all boards. This patch fixes this warning. Signed-off-by: Heiko Schocher <hs@denx.de> cc: Mike Frysinger <vapier@gentoo.org>
* lib, vsprintf: introduce strict_strtoulHeiko Schocher2011-05-12-0/+51
| | | | | | | | | | | | | | | as checkpatch proposes to use strict_strtoul instead of simple_strtoul, introduce it. Ported this function from Linux 2.6.38 commit ID: 521cb40b0c44418a4fd36dc633f575813d59a43d Signed-off-by: Heiko Schocher <hs@denx.de> cc: Wolfgang Denk <wd@denx.de> cc: Detlev Zundel <dzu@denx.de> cc: Valentin Longchamp <valentin.longchamp@keymile.com> cc: Holger Brunck <holger.brunck@keymile.com> Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
* do_reset: unify duplicate prototypesMike Frysinger2010-11-28-2/+0
| | | | | | | The duplication of the do_reset prototype has gotten out of hand, and they're not all in sync. Unify them all in command.h. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* Make sure that argv[] argument pointers are not modified.Wolfgang Denk2010-07-04-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hush shell dynamically allocates (and re-allocates) memory for the argument strings in the "char *argv[]" argument vector passed to commands. Any code that modifies these pointers will cause serious corruption of the malloc data structures and crash U-Boot, so make sure the compiler can check that no such modifications are being done by changing the code into "char * const argv[]". This modification is the result of debugging a strange crash caused after adding a new command, which used the following argument processing code which has been working perfectly fine in all Unix systems since version 6 - but not so in U-Boot: int main (int argc, char **argv) { while (--argc > 0 && **++argv == '-') { /* ====> */ while (*++*argv) { switch (**argv) { case 'd': debug++; break; ... default: usage (); } } } ... } The line marked "====>" will corrupt the malloc data structures and usually cause U-Boot to crash when the next command gets executed by the shell. With the modification, the compiler will prevent this with an error: increment of read-only location '*argv' N.B.: The code above can be trivially rewritten like this: while (--argc > 0 && **++argv == '-') { char *arg = *argv; while (*++arg) { switch (*arg) { ... Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* Rename lib_generic/ to lib/Peter Tyser2010-04-13-0/+681
Now that the other architecture-specific lib directories have been moved out of the top-level directory there's not much reason to have the '_generic' suffix on the common lib directory. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>