From 437716c5b4b900e9f8c95b0cefcfb4c0eb8db074 Mon Sep 17 00:00:00 2001 From: Eric Haszlakiewicz Date: Wed, 29 Nov 2017 09:25:11 -0500 Subject: [PATCH] Rename _set_last_err() to _json_c_set_last_err(). --- json_object.c | 4 ++-- json_object_private.h | 2 +- json_util.c | 18 +++++++++--------- json_util.h | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/json_object.c b/json_object.c index 08f9ac1..6cec62f 100644 --- a/json_object.c +++ b/json_object.c @@ -756,13 +756,13 @@ int json_c_set_serialization_double_format(const char *double_format, int global } tls_serialization_float_format = double_format ? strdup(double_format) : NULL; #else - _set_last_err("json_c_set_option: not compiled with __thread support\n"); + _json_c_set_last_err("json_c_set_option: not compiled with __thread support\n"); return -1; #endif } else { - _set_last_err("json_c_set_option: invalid global_or_thread value: %d\n", global_or_thread); + _json_c_set_last_err("json_c_set_option: invalid global_or_thread value: %d\n", global_or_thread); return -1; } return 0; diff --git a/json_object_private.h b/json_object_private.h index 1fe10be..325005a 100644 --- a/json_object_private.h +++ b/json_object_private.h @@ -48,7 +48,7 @@ struct json_object void *_userdata; }; -void _set_last_err(const char *err_fmt, ...); +void _json_c_set_last_err(const char *err_fmt, ...); #ifdef __cplusplus } diff --git a/json_util.c b/json_util.c index b5bcd07..ad7704a 100644 --- a/json_util.c +++ b/json_util.c @@ -72,7 +72,7 @@ const char *json_util_get_last_err() return _last_err; } -void _set_last_err(const char *err_fmt, ...) +void _json_c_set_last_err(const char *err_fmt, ...) { va_list ap; va_start(ap, err_fmt); @@ -89,14 +89,14 @@ struct json_object* json_object_from_fd(int fd) int ret; if(!(pb = printbuf_new())) { - _set_last_err("json_object_from_file: printbuf_new failed\n"); + _json_c_set_last_err("json_object_from_file: printbuf_new failed\n"); return NULL; } while((ret = read(fd, buf, JSON_FILE_BUF_SIZE)) > 0) { printbuf_memappend(pb, buf, ret); } if(ret < 0) { - _set_last_err("json_object_from_fd: error reading fd %d: %s\n", fd, strerror(errno)); + _json_c_set_last_err("json_object_from_fd: error reading fd %d: %s\n", fd, strerror(errno)); printbuf_free(pb); return NULL; } @@ -111,7 +111,7 @@ struct json_object* json_object_from_file(const char *filename) int fd; if((fd = open(filename, O_RDONLY)) < 0) { - _set_last_err("json_object_from_file: error opening file %s: %s\n", + _json_c_set_last_err("json_object_from_file: error opening file %s: %s\n", filename, strerror(errno)); return NULL; } @@ -128,12 +128,12 @@ int json_object_to_file_ext(const char *filename, struct json_object *obj, int f int saved_errno; if (!obj) { - _set_last_err("json_object_to_file: object is null\n"); + _json_c_set_last_err("json_object_to_file: object is null\n"); return -1; } if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0) { - _set_last_err("json_object_to_file: error opening file %s: %s\n", + _json_c_set_last_err("json_object_to_file: error opening file %s: %s\n", filename, strerror(errno)); return -1; } @@ -147,7 +147,7 @@ int json_object_to_file_ext(const char *filename, struct json_object *obj, int f int json_object_to_fd(int fd, struct json_object *obj, int flags) { if (!obj) { - _set_last_err("json_object_to_fd: object is null\n"); + _json_c_set_last_err("json_object_to_fd: object is null\n"); return -1; } @@ -169,7 +169,7 @@ static int _json_object_to_fd(int fd, struct json_object *obj, int flags, const wpos = 0; while(wpos < wsize) { if((ret = write(fd, json_str + wpos, wsize-wpos)) < 0) { - _set_last_err("json_object_to_file: error writing file %s: %s\n", + _json_c_set_last_err("json_object_to_file: error writing file %s: %s\n", filename, strerror(errno)); return -1; } @@ -235,7 +235,7 @@ const char *json_type_to_name(enum json_type o_type) int o_type_int = (int)o_type; if (o_type_int < 0 || o_type_int >= (int)NELEM(json_type_name)) { - _set_last_err("json_type_to_name: type %d is out of range [0,%d]\n", o_type, NELEM(json_type_name)); + _json_c_set_last_err("json_type_to_name: type %d is out of range [0,%d]\n", o_type, NELEM(json_type_name)); return NULL; } return json_type_name[o_type]; diff --git a/json_util.h b/json_util.h index d8926db..8f9fe8b 100644 --- a/json_util.h +++ b/json_util.h @@ -77,8 +77,8 @@ extern int json_object_to_file_ext(const char *filename, struct json_object *obj extern int json_object_to_fd(int fd, struct json_object *obj, int flags); /** - * Return the last error from json_object_to_file{,_ext}, - * json_object_to_fd() or + * Return the last error from various json-c functions, including: + * json_object_to_file{,_ext}, json_object_to_fd() or * json_object_from_{file,fd}, or NULL if there is none. */ const char *json_util_get_last_err(void);