1
0
Fork 0
forked from len0rd/rockbox

format() (and its alias vuprintf) return values are uncheck -> void

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28119 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Rafaël Carré 2010-09-20 08:55:45 +00:00
parent cc6ef19dd9
commit 5a98ad2d7f
3 changed files with 8 additions and 12 deletions

View file

@ -29,7 +29,7 @@
static const char hexdigit[] = "0123456789ABCDEF"; static const char hexdigit[] = "0123456789ABCDEF";
int format( void format(
/* call 'push()' for each output letter */ /* call 'push()' for each output letter */
int (*push)(void *userp, unsigned char data), int (*push)(void *userp, unsigned char data),
void *userp, void *userp,
@ -220,7 +220,6 @@ int format(
else else
ok=push(userp, ch); ok=push(userp, ch);
} }
return ok; /* true means good */
} }
struct for_fprintf { struct for_fprintf {
@ -244,7 +243,6 @@ static int fprfunc(void *pr, unsigned char letter)
int fdprintf(int fd, const char *fmt, ...) int fdprintf(int fd, const char *fmt, ...)
{ {
bool ok;
va_list ap; va_list ap;
struct for_fprintf fpr; struct for_fprintf fpr;
@ -252,13 +250,13 @@ int fdprintf(int fd, const char *fmt, ...)
fpr.bytes=0; fpr.bytes=0;
va_start(ap, fmt); va_start(ap, fmt);
ok = format(fprfunc, &fpr, fmt, ap); format(fprfunc, &fpr, fmt, ap);
va_end(ap); va_end(ap);
return fpr.bytes; /* return 0 on error */ return fpr.bytes; /* return 0 on error */
} }
int vuprintf(int (*push)(void *userp, unsigned char data), void *userp, const char *fmt, va_list ap) void vuprintf(int (*push)(void *userp, unsigned char data), void *userp, const char *fmt, va_list ap)
{ {
return format(push, userp, fmt, ap); format(push, userp, fmt, ap);
} }

View file

@ -22,7 +22,7 @@
#ifndef __FORMAT_H__ #ifndef __FORMAT_H__
#define __FORMAT_H__ #define __FORMAT_H__
int format( void format(
/* call 'push()' for each output letter */ /* call 'push()' for each output letter */
int (*push)(void *userp, unsigned char data), int (*push)(void *userp, unsigned char data),
void *userp, void *userp,
@ -31,7 +31,7 @@ int format(
/* callback function is called for every output character (byte) with userp and /* callback function is called for every output character (byte) with userp and
* should return 0 when ch is a char other than '\0' that should stop printing */ * should return 0 when ch is a char other than '\0' that should stop printing */
int vuprintf(int (*push)(void *userp, unsigned char data), void vuprintf(int (*push)(void *userp, unsigned char data),
void *userp, const char *fmt, va_list ap); void *userp, const char *fmt, va_list ap);
#endif /* __FORMAT_H__ */ #endif /* __FORMAT_H__ */

View file

@ -57,7 +57,6 @@ static int sprfunc(void *ptr, unsigned char letter)
int snprintf(char *buf, size_t size, const char *fmt, ...) int snprintf(char *buf, size_t size, const char *fmt, ...)
{ {
bool ok;
va_list ap; va_list ap;
struct for_snprintf pr; struct for_snprintf pr;
@ -66,7 +65,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
pr.max = size; pr.max = size;
va_start(ap, fmt); va_start(ap, fmt);
ok = format(sprfunc, &pr, fmt, ap); format(sprfunc, &pr, fmt, ap);
va_end(ap); va_end(ap);
/* make sure it ends with a trailing zero */ /* make sure it ends with a trailing zero */
@ -77,14 +76,13 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap) int vsnprintf(char *buf, size_t size, const char *fmt, va_list ap)
{ {
bool ok;
struct for_snprintf pr; struct for_snprintf pr;
pr.ptr = (unsigned char *)buf; pr.ptr = (unsigned char *)buf;
pr.bytes = 0; pr.bytes = 0;
pr.max = size; pr.max = size;
ok = format(sprfunc, &pr, fmt, ap); format(sprfunc, &pr, fmt, ap);
/* make sure it ends with a trailing zero */ /* make sure it ends with a trailing zero */
pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0'; pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';