Skip to content

Commit 489ae5f

Browse files
committed
Refine
1 parent 79d8efc commit 489ae5f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/io.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int io_init(void)
132132
log_error("epoll_ctl(STDOUT_FILENO) error (%d)\n", errno);
133133
if (close(stdout_epollfd) < 0)
134134
{
135-
log_error("close(stdout_epollfd) error (%d)\n");
135+
log_error("close(stdout_epollfd) error (%d)\n", errno);
136136
}
137137
stdout_epollfd = -1;
138138
return -1;
@@ -214,7 +214,7 @@ void io_cleanup(void)
214214

215215
if (close(stdout_epollfd) < 0)
216216
{
217-
log_error("close(stdout_epollfd) error (%d)\n");
217+
log_error("close(stdout_epollfd) error (%d)\n", errno);
218218
}
219219
stdout_epollfd = -1;
220220
}
@@ -262,6 +262,7 @@ int prints(const char *format, ...)
262262
errno = EAGAIN;
263263
int need = stdout_buf_len + ret - OUTPUT_BUF_SIZE;
264264
log_error("Output buffer is full, additional %d is required\n", need);
265+
ret = -1;
265266
}
266267
}
267268

@@ -1166,7 +1167,8 @@ int io_buf_conv(iconv_t cd, char *p_buf, int *p_buf_len, int *p_buf_offset, char
11661167
{
11671168
if (errno == EINVAL) // Incomplete
11681169
{
1169-
log_debug("iconv(inbytes=%ld, outbytes=%ld) error: EINVAL, in_buf[0]=%d\n", in_bytes, out_bytes, in_buf[0]);
1170+
log_debug("iconv(inbytes=%zu, outbytes=%zu) error: EINVAL, in_buf[0]=%d\n",
1171+
in_bytes, out_bytes, (unsigned char)in_buf[0]);
11701172
if (p_buf != in_buf)
11711173
{
11721174
*p_buf_len -= (int)(in_buf - p_buf);
@@ -1179,32 +1181,32 @@ int io_buf_conv(iconv_t cd, char *p_buf, int *p_buf_len, int *p_buf_offset, char
11791181
}
11801182
else if (errno == E2BIG)
11811183
{
1182-
log_error("iconv(inbytes=%ld, outbytes=%ld) error: E2BIG\n", in_bytes, out_bytes);
1184+
log_error("iconv(inbytes=%zu, outbytes=%zu) error: E2BIG\n", in_bytes, out_bytes);
11831185
return -1;
11841186
}
11851187
else if (errno == EILSEQ)
11861188
{
11871189
if (in_bytes > out_bytes || out_bytes <= 0)
11881190
{
1189-
log_error("iconv(inbytes=%ld, outbytes=%ld) error: EILSEQ and E2BIG\n", in_bytes, out_bytes);
1191+
log_error("iconv(inbytes=%zu, outbytes=%zu) error: EILSEQ\n", in_bytes, out_bytes);
11901192
return -2;
11911193
}
11921194

11931195
// reset in_bytes when "//IGNORE" is applied
11941196
if (in_bytes == 0)
11951197
{
11961198
in_bytes = (size_t)(*p_buf_len - *p_buf_offset);
1197-
log_debug("Reset in_bytes from 0 to %ld\n", in_bytes);
1199+
log_debug("Reset in_bytes from 0 to %zu\n", in_bytes);
11981200
}
11991201

1200-
log_debug("iconv(in_bytes=%ld, out_bytes=%ld) error: EILSEQ, in_buf[0]=%d\n",
1201-
in_bytes, out_bytes, in_buf[0]);
1202+
log_debug("iconv(in_bytes=%zu, out_bytes=%zu) error: EILSEQ, in_buf[0]=%d\n",
1203+
in_bytes, out_bytes, (unsigned char)in_buf[0]);
12021204
skip_current = 1;
12031205
}
12041206
else // something strange
12051207
{
1206-
log_debug("iconv(in_bytes=%ld, out_bytes=%ld) error: %d, in_buf[0]=%d\n",
1207-
in_bytes, out_bytes, errno, in_buf[0]);
1208+
log_debug("iconv(in_bytes=%zu, out_bytes=%zu) error: %d, in_buf[0]=%d\n",
1209+
in_bytes, out_bytes, errno, (unsigned char)in_buf[0]);
12081210
*p_buf_offset = (int)(in_buf - p_buf);
12091211
*p_conv_len = (int)(conv_size - out_bytes);
12101212
skip_current = 1;

0 commit comments

Comments
 (0)