mirror of
https://github.com/json-c/json-c.git
synced 2026-03-20 13:39:06 +08:00
Fix error messages
Error messages did not reflect actual function names.
This commit is contained in:
@@ -945,14 +945,15 @@ int json_c_set_serialization_double_format(const char *double_format, int global
|
|||||||
}
|
}
|
||||||
tls_serialization_float_format = double_format ? strdup(double_format) : NULL;
|
tls_serialization_float_format = double_format ? strdup(double_format) : NULL;
|
||||||
#else
|
#else
|
||||||
_json_c_set_last_err("json_c_set_option: not compiled with __thread support\n");
|
_json_c_set_last_err("json_c_set_set_serialization_double_format: not compiled "
|
||||||
|
"with __thread support\n");
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_json_c_set_last_err("json_c_set_option: invalid global_or_thread value: %d\n",
|
_json_c_set_last_err("json_c_set_serialization_double_format: invalid "
|
||||||
global_or_thread);
|
"global_or_thread value: %d\n", global_or_thread);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
18
json_util.c
18
json_util.c
@@ -91,7 +91,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
|
|||||||
|
|
||||||
if (!(pb = printbuf_new()))
|
if (!(pb = printbuf_new()))
|
||||||
{
|
{
|
||||||
_json_c_set_last_err("json_object_from_file: printbuf_new failed\n");
|
_json_c_set_last_err("json_object_from_fd_ex: printbuf_new failed\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
|
|||||||
if (!tok)
|
if (!tok)
|
||||||
{
|
{
|
||||||
_json_c_set_last_err(
|
_json_c_set_last_err(
|
||||||
"json_object_from_fd: unable to allocate json_tokener(depth=%d): %s\n", depth,
|
"json_object_from_fd_ex: unable to allocate json_tokener(depth=%d): %s\n", depth,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
printbuf_free(pb);
|
printbuf_free(pb);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -113,7 +113,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
|
|||||||
}
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
_json_c_set_last_err("json_object_from_fd: error reading fd %d: %s\n", fd,
|
_json_c_set_last_err("json_object_from_fd_ex: error reading fd %d: %s\n", fd,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
json_tokener_free(tok);
|
json_tokener_free(tok);
|
||||||
printbuf_free(pb);
|
printbuf_free(pb);
|
||||||
@@ -137,8 +137,8 @@ struct json_object *json_object_from_file(const char *filename)
|
|||||||
|
|
||||||
if ((fd = open(filename, O_RDONLY)) < 0)
|
if ((fd = open(filename, O_RDONLY)) < 0)
|
||||||
{
|
{
|
||||||
_json_c_set_last_err("json_object_from_file: error opening file %s: %s\n", filename,
|
_json_c_set_last_err("json_object_from_file: error opening file %s: %s\n",
|
||||||
strerror(errno));
|
filename, strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
obj = json_object_from_fd(fd);
|
obj = json_object_from_fd(fd);
|
||||||
@@ -155,14 +155,14 @@ int json_object_to_file_ext(const char *filename, struct json_object *obj, int f
|
|||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
_json_c_set_last_err("json_object_to_file: object is null\n");
|
_json_c_set_last_err("json_object_to_file_ext: object is null\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0)
|
if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0)
|
||||||
{
|
{
|
||||||
_json_c_set_last_err("json_object_to_file: error opening file %s: %s\n", filename,
|
_json_c_set_last_err("json_object_to_file_ext: error opening file %s: %s\n",
|
||||||
strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = _json_object_to_fd(fd, obj, flags, filename);
|
ret = _json_object_to_fd(fd, obj, flags, filename);
|
||||||
@@ -202,7 +202,7 @@ static int _json_object_to_fd(int fd, struct json_object *obj, int flags, const
|
|||||||
{
|
{
|
||||||
if ((ret = write(fd, json_str + wpos, wsize - wpos)) < 0)
|
if ((ret = write(fd, json_str + wpos, wsize - wpos)) < 0)
|
||||||
{
|
{
|
||||||
_json_c_set_last_err("json_object_to_file: error writing file %s: %s\n",
|
_json_c_set_last_err("json_object_to_fd: error writing file %s: %s\n",
|
||||||
filename, strerror(errno));
|
filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user