diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/common/format.c | 10 | ||||
-rw-r--r-- | firmware/include/format.h | 4 | ||||
-rw-r--r-- | firmware/libc/sprintf.c | 6 |
3 files changed, 8 insertions, 12 deletions
diff --git a/firmware/common/format.c b/firmware/common/format.c index 240dd1ebd5..afe1010cfb 100644 --- a/firmware/common/format.c +++ b/firmware/common/format.c | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | static const char hexdigit[] = "0123456789ABCDEF"; | 30 | static const char hexdigit[] = "0123456789ABCDEF"; |
31 | 31 | ||
32 | int format( | 32 | void format( |
33 | /* call 'push()' for each output letter */ | 33 | /* call 'push()' for each output letter */ |
34 | int (*push)(void *userp, unsigned char data), | 34 | int (*push)(void *userp, unsigned char data), |
35 | void *userp, | 35 | void *userp, |
@@ -220,7 +220,6 @@ int format( | |||
220 | else | 220 | else |
221 | ok=push(userp, ch); | 221 | ok=push(userp, ch); |
222 | } | 222 | } |
223 | return ok; /* true means good */ | ||
224 | } | 223 | } |
225 | 224 | ||
226 | struct for_fprintf { | 225 | struct for_fprintf { |
@@ -244,7 +243,6 @@ static int fprfunc(void *pr, unsigned char letter) | |||
244 | 243 | ||
245 | int fdprintf(int fd, const char *fmt, ...) | 244 | int fdprintf(int fd, const char *fmt, ...) |
246 | { | 245 | { |
247 | bool ok; | ||
248 | va_list ap; | 246 | va_list ap; |
249 | struct for_fprintf fpr; | 247 | struct for_fprintf fpr; |
250 | 248 | ||
@@ -252,13 +250,13 @@ int fdprintf(int fd, const char *fmt, ...) | |||
252 | fpr.bytes=0; | 250 | fpr.bytes=0; |
253 | 251 | ||
254 | va_start(ap, fmt); | 252 | va_start(ap, fmt); |
255 | ok = format(fprfunc, &fpr, fmt, ap); | 253 | format(fprfunc, &fpr, fmt, ap); |
256 | va_end(ap); | 254 | va_end(ap); |
257 | 255 | ||
258 | return fpr.bytes; /* return 0 on error */ | 256 | return fpr.bytes; /* return 0 on error */ |
259 | } | 257 | } |
260 | 258 | ||
261 | int vuprintf(int (*push)(void *userp, unsigned char data), void *userp, const char *fmt, va_list ap) | 259 | void vuprintf(int (*push)(void *userp, unsigned char data), void *userp, const char *fmt, va_list ap) |
262 | { | 260 | { |
263 | return format(push, userp, fmt, ap); | 261 | format(push, userp, fmt, ap); |
264 | } | 262 | } |
diff --git a/firmware/include/format.h b/firmware/include/format.h index 6a00574644..30a072aca8 100644 --- a/firmware/include/format.h +++ b/firmware/include/format.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #ifndef __FORMAT_H__ | 22 | #ifndef __FORMAT_H__ |
23 | #define __FORMAT_H__ | 23 | #define __FORMAT_H__ |
24 | 24 | ||
25 | int format( | 25 | void format( |
26 | /* call 'push()' for each output letter */ | 26 | /* call 'push()' for each output letter */ |
27 | int (*push)(void *userp, unsigned char data), | 27 | int (*push)(void *userp, unsigned char data), |
28 | void *userp, | 28 | void *userp, |
@@ -31,7 +31,7 @@ int format( | |||
31 | 31 | ||
32 | /* callback function is called for every output character (byte) with userp and | 32 | /* callback function is called for every output character (byte) with userp and |
33 | * should return 0 when ch is a char other than '\0' that should stop printing */ | 33 | * should return 0 when ch is a char other than '\0' that should stop printing */ |
34 | int vuprintf(int (*push)(void *userp, unsigned char data), | 34 | void vuprintf(int (*push)(void *userp, unsigned char data), |
35 | void *userp, const char *fmt, va_list ap); | 35 | void *userp, const char *fmt, va_list ap); |
36 | 36 | ||
37 | #endif /* __FORMAT_H__ */ | 37 | #endif /* __FORMAT_H__ */ |
diff --git a/firmware/libc/sprintf.c b/firmware/libc/sprintf.c index b02f5a2fae..18e2ce6fd2 100644 --- a/firmware/libc/sprintf.c +++ b/firmware/libc/sprintf.c | |||
@@ -57,7 +57,6 @@ static int sprfunc(void *ptr, unsigned char letter) | |||
57 | 57 | ||
58 | int snprintf(char *buf, size_t size, const char *fmt, ...) | 58 | int snprintf(char *buf, size_t size, const char *fmt, ...) |
59 | { | 59 | { |
60 | bool ok; | ||
61 | va_list ap; | 60 | va_list ap; |
62 | struct for_snprintf pr; | 61 | struct for_snprintf pr; |
63 | 62 | ||
@@ -66,7 +65,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...) | |||
66 | pr.max = size; | 65 | pr.max = size; |
67 | 66 | ||
68 | va_start(ap, fmt); | 67 | va_start(ap, fmt); |
69 | ok = format(sprfunc, &pr, fmt, ap); | 68 | format(sprfunc, &pr, fmt, ap); |
70 | va_end(ap); | 69 | va_end(ap); |
71 | 70 | ||
72 | /* make sure it ends with a trailing zero */ | 71 | /* make sure it ends with a trailing zero */ |
@@ -77,14 +76,13 @@ int snprintf(char *buf, size_t size, const char *fmt, ...) | |||
77 | 76 | ||
78 | int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap) | 77 | int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap) |
79 | { | 78 | { |
80 | bool ok; | ||
81 | struct for_snprintf pr; | 79 | struct for_snprintf pr; |
82 | 80 | ||
83 | pr.ptr = (unsigned char *)buf; | 81 | pr.ptr = (unsigned char *)buf; |
84 | pr.bytes = 0; | 82 | pr.bytes = 0; |
85 | pr.max = size; | 83 | pr.max = size; |
86 | 84 | ||
87 | ok = format(sprfunc, &pr, fmt, ap); | 85 | format(sprfunc, &pr, fmt, ap); |
88 | 86 | ||
89 | /* make sure it ends with a trailing zero */ | 87 | /* make sure it ends with a trailing zero */ |
90 | pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0'; | 88 | pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0'; |