diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-09-25 13:36:35 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-09-25 13:36:35 -0400 |
commit | d6f9cfcf2d3e39894f458b8b96e3fb593b523842 (patch) | |
tree | bf4d3d5e596aa8c12336b6104004cfd4621bf375 | |
parent | b01bb016a28296563cfddb5634726ed51fd720e0 (diff) |
use C99 language features for C99 library functions
-rw-r--r-- | src/stdio/snprintf.c | 14 | ||||
-rw-r--r-- | src/stdio/vfscanf.c | 12 | ||||
-rw-r--r-- | src/stdio/vsnprintf.c | 14 | ||||
-rw-r--r-- | src/stdio/vsscanf.c | 12 |
4 files changed, 27 insertions, 25 deletions
diff --git a/src/stdio/snprintf.c b/src/stdio/snprintf.c index 44bb65fe..a6896c8a 100644 --- a/src/stdio/snprintf.c +++ b/src/stdio/snprintf.c @@ -4,15 +4,17 @@ int snprintf(char * restrict s, size_t n, const char * restrict format, ...) { - int ret = 0; + struct io_options opt = { + .fnname = __func__, + .string = s, + .maxlen = n, + }; + va_list ap; - struct io_options opt = {0}; - opt.fnname = __func__; - opt.string = s; - opt.maxlen = n; va_start(ap, format); - ret = __printf(&opt, format, ap); + int ret = __printf(&opt, format, ap); va_end(ap); + return ret; } diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index ad9f5614..99053885 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -3,12 +3,12 @@ int vfscanf(FILE * restrict stream, const char * restrict format, va_list arg) { - int ret = 0; - struct io_options opt = {0}; - opt.fnname = __func__; - opt.stream = stream; - ret = __scanf(&opt, format, arg); - return ret; + struct io_options opt = { + .fnname = __func__, + .stream = stream, + }; + + return __scanf(&opt, format, arg); } /* diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c index 62963b2c..92753a90 100644 --- a/src/stdio/vsnprintf.c +++ b/src/stdio/vsnprintf.c @@ -4,13 +4,13 @@ int vsnprintf(char * restrict s, size_t n, const char *format, va_list arg) { - int ret = 0; - struct io_options opt = {0}; - opt.fnname = "fprintf"; - opt.string = s; - opt.maxlen = n; - ret = __printf(&opt, format, arg); - return ret; + struct io_options opt = { + .fnname = __func__, + .string = s, + .maxlen = n, + }; + + return __printf(&opt, format, arg); } /* diff --git a/src/stdio/vsscanf.c b/src/stdio/vsscanf.c index 2573b213..dcf40db8 100644 --- a/src/stdio/vsscanf.c +++ b/src/stdio/vsscanf.c @@ -4,12 +4,12 @@ int vsscanf(const char * restrict s, const char * restrict format, va_list arg) { - int ret = 0; - struct io_options opt = {0}; - opt.fnname = __func__; - opt.string = (char*)s; - ret = __scanf(&opt, format, arg); - return ret; + struct io_options opt = { + .fnname = __func__, + .string = (char*)s, + }; + + return __scanf(&opt, format, arg); } /* |