diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2014-11-28 17:23:32 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2014-11-28 17:23:32 +1100 |
commit | 124591c0f398341c0262ee2804c08c6f0e2dbdf6 (patch) | |
tree | e7cc9a17a0c3a6e1818264d54bbc79b61a095ec4 | |
parent | 209611863a21e335daff50a94257d0f7fd145cdc (diff) | |
download | skiboot-124591c0f398341c0262ee2804c08c6f0e2dbdf6.zip skiboot-124591c0f398341c0262ee2804c08c6f0e2dbdf6.tar.gz skiboot-124591c0f398341c0262ee2804c08c6f0e2dbdf6.tar.bz2 |
Remove sprintf: there's no good reason to have this in firmware
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | core/pel.c | 6 | ||||
-rw-r--r-- | hdata/memory.c | 2 | ||||
-rw-r--r-- | libc/include/stdio.h | 1 | ||||
-rw-r--r-- | libc/stdio/Makefile.inc | 2 | ||||
-rw-r--r-- | libc/stdio/sprintf.c | 30 | ||||
-rw-r--r-- | platforms/astbmc/common.c | 8 | ||||
-rw-r--r-- | platforms/ibm-fsp/firenze.c | 4 | ||||
-rw-r--r-- | platforms/rhesus/rhesus.c | 2 |
8 files changed, 12 insertions, 43 deletions
@@ -67,7 +67,7 @@ static void create_extended_header_section(struct errorlog *elog_data, static void settype(struct opal_src_section *src, uint8_t src_type) { char type[4]; - sprintf(type, "%02X", src_type); + snprintf(type, sizeof(type), "%02X", src_type); memcpy(src->srcstring, type, 2); } @@ -75,7 +75,7 @@ static void settype(struct opal_src_section *src, uint8_t src_type) static void setsubsys(struct opal_src_section *src, uint8_t src_subsys) { char subsys[4]; - sprintf(subsys, "%02X", src_subsys); + snprintf(subsys, sizeof(subsys), "%02X", src_subsys); memcpy(src->srcstring+2, subsys, 2); } @@ -83,7 +83,7 @@ static void setsubsys(struct opal_src_section *src, uint8_t src_subsys) static void setrefcode(struct opal_src_section *src, uint16_t src_refcode) { char refcode[8]; - sprintf(refcode, "%04X", src_refcode); + snprintf(refcode, sizeof(refcode), "%04X", src_refcode); memcpy(src->srcstring+4, refcode, 4); } diff --git a/hdata/memory.c b/hdata/memory.c index 36a6682..d6e87cb 100644 --- a/hdata/memory.c +++ b/hdata/memory.c @@ -139,7 +139,7 @@ static bool add_address_range(struct dt_node *root, return true; } } - sprintf(name, "memory@%llx", (long long)reg[0]); + snprintf(name, sizeof(name), "memory@%llx", (long long)reg[0]); mem = dt_new(root, name); dt_add_property_string(mem, "device_type", "memory"); diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 57d655a..6dd82c3 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -42,7 +42,6 @@ extern FILE stderr_data; int fileno(FILE *stream); int printf(const char *format, ...) __attribute__((format (printf, 1, 2))); int fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3))); -int sprintf(char *str, const char *format, ...) __attribute__((format (printf, 2, 3))); int snprintf(char *str, size_t size, const char *format, ...) __attribute__((format (printf, 3, 4))); int vfprintf(FILE *stream, const char *format, va_list); int vsprintf(char *str, const char *format, va_list); diff --git a/libc/stdio/Makefile.inc b/libc/stdio/Makefile.inc index f375f93..025ee01 100644 --- a/libc/stdio/Makefile.inc +++ b/libc/stdio/Makefile.inc @@ -13,7 +13,7 @@ SUBDIRS += $(LIBCDIR)/stdio -STDIO_OBJS = fscanf.o sprintf.o vfprintf.o vsnprintf.o vsprintf.o fprintf.o \ +STDIO_OBJS = fscanf.o vfprintf.o vsnprintf.o vsprintf.o fprintf.o \ setvbuf.o fputc.o puts.o fputs.o putchar.o scanf.o \ stdchnls.o vfscanf.o vsscanf.o fileno.o snprintf.o diff --git a/libc/stdio/sprintf.c b/libc/stdio/sprintf.c deleted file mode 100644 index 9c4540e..0000000 --- a/libc/stdio/sprintf.c +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdio.h> - - -int sprintf(char *buff, const char *format, ...) -{ - va_list ar; - int count; - - if ((buff==NULL) || (format==NULL)) - return(-1); - - va_start(ar, format); - count = vsprintf(buff, format, ar); - va_end(ar); - - return(count); -} - diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c index b9aae95..df79733 100644 --- a/platforms/astbmc/common.c +++ b/platforms/astbmc/common.c @@ -89,7 +89,7 @@ static void astbmc_fixup_dt_bt(struct dt_node *lpc) return; } - sprintf(namebuf, "ipmi-bt@i%x", BT_IO_BASE); + snprintf(namebuf, sizeof(namebuf), "ipmi-bt@i%x", BT_IO_BASE); bt = dt_new(lpc, namebuf); dt_add_property_cells(bt, "reg", @@ -122,7 +122,7 @@ static void astbmc_fixup_dt_uart(struct dt_node *lpc) } /* Otherwise, add a node for it */ - sprintf(namebuf, "serial@i%x", UART_IO_BASE); + snprintf(namebuf, sizeof(namebuf), "serial@i%x", UART_IO_BASE); uart = dt_new(lpc, namebuf); dt_add_property_cells(uart, "reg", @@ -229,10 +229,10 @@ static void astbmc_fixup_dt_i2cm(void) master = dt_create_i2c_master(c->devnode, 1); assert(master); - sprintf(name,"p8_%08x_e%dp%d", c->id, 1, 0); + snprintf(name, sizeof(name), "p8_%08x_e%dp%d", c->id, 1, 0); bus = dt_create_i2c_bus(master, name, 0); assert(bus); - sprintf(name,"p8_%08x_e%dp%d", c->id, 1, 2); + snprintf(name, sizeof(name), "p8_%08x_e%dp%d", c->id, 1, 2); bus = dt_create_i2c_bus(master, name, 2); assert(bus); dt_create_i2c_device(bus, 0x50, "eeprom", "atmel,24c256", "system-vpd"); diff --git a/platforms/ibm-fsp/firenze.c b/platforms/ibm-fsp/firenze.c index 331b48a..bad40c4 100644 --- a/platforms/ibm-fsp/firenze.c +++ b/platforms/ibm-fsp/firenze.c @@ -135,7 +135,7 @@ static void firenze_dt_fixup_i2cm(void) /* Engine 1 */ master = dt_create_i2c_master(c->devnode, 1); assert(master); - sprintf(name,"p8_%08x_e%dp%d", c->id, 1, 0); + snprintf(name, sizeof(name), "p8_%08x_e%dp%d", c->id, 1, 0); bus = dt_create_i2c_bus(master, name, 0); assert(bus); dt_create_i2c_device(bus, 0x39, "slot-C4-C5", "maxim,5961", @@ -152,7 +152,7 @@ static void firenze_dt_fixup_i2cm(void) /* Engine 1*/ master = dt_create_i2c_master(c->devnode, 1); assert(master); - sprintf(name,"p8_%08x_e%dp%d", c->id, 1, 0); + snprintf(name, sizeof(name), "p8_%08x_e%dp%d", c->id, 1, 0); bus = dt_create_i2c_bus(master, name, 0); assert(bus); dt_create_i2c_device(bus, 0x32, "slot-C10-C11", "maxim,5961", diff --git a/platforms/rhesus/rhesus.c b/platforms/rhesus/rhesus.c index bcf67ee..8385a0c 100644 --- a/platforms/rhesus/rhesus.c +++ b/platforms/rhesus/rhesus.c @@ -202,7 +202,7 @@ static void rhesus_dt_fixup_uart(struct dt_node *lpc) #define UART_IO_BASE 0x3f8 #define UART_IO_COUNT 8 - sprintf(namebuf, "serial@i%x", UART_IO_BASE); + snprintf(namebuf, sizeof(namebuf), "serial@i%x", UART_IO_BASE); uart = dt_new(lpc, namebuf); dt_add_property_cells(uart, "reg", |