Skip to content

Commit 79459b2

Browse files
authored
Merge pull request json-c#755 from c3h2-ctf/error
Fix error messages
2 parents 2326e34 + 6e53347 commit 79459b2

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

Diff for: json_object.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -945,14 +945,15 @@ int json_c_set_serialization_double_format(const char *double_format, int global
945945
}
946946
tls_serialization_float_format = double_format ? strdup(double_format) : NULL;
947947
#else
948-
_json_c_set_last_err("json_c_set_option: not compiled with __thread support\n");
948+
_json_c_set_last_err("json_c_set_set_serialization_double_format: not compiled "
949+
"with __thread support\n");
949950
return -1;
950951
#endif
951952
}
952953
else
953954
{
954-
_json_c_set_last_err("json_c_set_option: invalid global_or_thread value: %d\n",
955-
global_or_thread);
955+
_json_c_set_last_err("json_c_set_serialization_double_format: invalid "
956+
"global_or_thread value: %d\n", global_or_thread);
956957
return -1;
957958
}
958959
return 0;

Diff for: json_util.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
9191

9292
if (!(pb = printbuf_new()))
9393
{
94-
_json_c_set_last_err("json_object_from_file: printbuf_new failed\n");
94+
_json_c_set_last_err("json_object_from_fd_ex: printbuf_new failed\n");
9595
return NULL;
9696
}
9797

@@ -101,7 +101,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
101101
if (!tok)
102102
{
103103
_json_c_set_last_err(
104-
"json_object_from_fd: unable to allocate json_tokener(depth=%d): %s\n", depth,
104+
"json_object_from_fd_ex: unable to allocate json_tokener(depth=%d): %s\n", depth,
105105
strerror(errno));
106106
printbuf_free(pb);
107107
return NULL;
@@ -113,7 +113,7 @@ struct json_object *json_object_from_fd_ex(int fd, int in_depth)
113113
}
114114
if (ret < 0)
115115
{
116-
_json_c_set_last_err("json_object_from_fd: error reading fd %d: %s\n", fd,
116+
_json_c_set_last_err("json_object_from_fd_ex: error reading fd %d: %s\n", fd,
117117
strerror(errno));
118118
json_tokener_free(tok);
119119
printbuf_free(pb);
@@ -137,8 +137,8 @@ struct json_object *json_object_from_file(const char *filename)
137137

138138
if ((fd = open(filename, O_RDONLY)) < 0)
139139
{
140-
_json_c_set_last_err("json_object_from_file: error opening file %s: %s\n", filename,
141-
strerror(errno));
140+
_json_c_set_last_err("json_object_from_file: error opening file %s: %s\n",
141+
filename, strerror(errno));
142142
return NULL;
143143
}
144144
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
155155

156156
if (!obj)
157157
{
158-
_json_c_set_last_err("json_object_to_file: object is null\n");
158+
_json_c_set_last_err("json_object_to_file_ext: object is null\n");
159159
return -1;
160160
}
161161

162162
if ((fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0)
163163
{
164-
_json_c_set_last_err("json_object_to_file: error opening file %s: %s\n", filename,
165-
strerror(errno));
164+
_json_c_set_last_err("json_object_to_file_ext: error opening file %s: %s\n",
165+
filename, strerror(errno));
166166
return -1;
167167
}
168168
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
202202
{
203203
if ((ret = write(fd, json_str + wpos, wsize - wpos)) < 0)
204204
{
205-
_json_c_set_last_err("json_object_to_file: error writing file %s: %s\n",
205+
_json_c_set_last_err("json_object_to_fd: error writing file %s: %s\n",
206206
filename, strerror(errno));
207207
return -1;
208208
}

0 commit comments

Comments
 (0)