jcs
/subtext
/amendments
/481
binkp+board+fidopkt: Log more errors, avoid warn() when possible
jcs made amendment 481 about 1 year ago
--- binkp.c Mon Mar 27 21:30:29 2023
+++ binkp.c Mon Apr 17 15:10:38 2023
@@ -1060,9 +1060,11 @@ binkp_scan_message(struct fidopkt_message *msg)
size = fidopkt_encode_message(msg, &buf,
db->config.ftn_hub_pkt_password, db->config.timezone_utcoff);
- if (size == 0)
+ if (size == 0) {
+ logger_printf("[binkp] Failed encoding fidopkt during scan");
return false;
-
+ }
+
snprintf(filename, sizeof(filename), "%c%07lx.pkt",
msg->area[0] ? 'b' : 'm', msg->msgid.id & 0x0fffffff);
--- board.c Mon Apr 10 16:30:58 2023
+++ board.c Mon Apr 17 15:09:50 2023
@@ -1210,7 +1210,8 @@ board_post_create(struct board *board, struct board_th
user = user_username(post->sender_user_id);
if (user == NULL) {
- warn("can't find username of user posting new message?");
+ logger_printf("[board] Can't find username of user posting "
+ "new message");
post->id = 0;
goto done;
}
@@ -1249,7 +1250,8 @@ board_post_create(struct board *board, struct board_th
strlcpy(fidomsg.origin, ftn_post.origin, sizeof(fidomsg.origin));
if (!binkp_scan_message(&fidomsg)) {
- warn("failed scanning fidopkt");
+ logger_printf("[board] Failed scanning new FTN message being "
+ "posted");
post->id = 0;
goto done;
}
@@ -1258,7 +1260,7 @@ board_post_create(struct board *board, struct board_th
board_ftn_post_object_fields, nboard_ftn_post_object_fields,
&ftn_post, &data, &size);
if (ret != 0 || size == 0) {
- warn("failed to marshall new FTN post object");
+ logger_printf("[board] Failed to marshall new FTN post object");
post->id = 0;
goto done;
}
@@ -1286,7 +1288,7 @@ board_post_create(struct board *board, struct board_th
ret = bile_marshall_object(board->bile, board_post_object_fields,
nboard_post_object_fields, post, &data, &size);
if (ret != 0 || size == 0) {
- warn("failed to marshall new post object");
+ logger_printf("[board] Failed to marshall new post object");
post->id = 0;
goto done;
}
@@ -1341,7 +1343,7 @@ board_post_create(struct board *board, struct board_th
ret = bile_marshall_object(board->bile, board_thread_object_fields,
nboard_thread_object_fields, thread, &data, &size);
if (ret != 0 || size == 0) {
- warn("failed to marshall thread object");
+ logger_printf("[board] Failed to marshall new thread object");
post->id = 0;
goto done;
}
@@ -1431,7 +1433,8 @@ board_delete_post(struct board *board, struct board_po
ret = bile_marshall_object(board->bile, board_thread_object_fields,
nboard_thread_object_fields, thread, &data, &size);
if (ret != 0 || size == 0) {
- warn("failed to marshall thread object during post delete");
+ logger_printf("[board] Failed to marshall thread object "
+ "during post deletion");
return;
}
if (bile_write(board->bile, BOARD_THREAD_RTYPE, thread->thread_id,
@@ -1464,7 +1467,7 @@ board_delete_post(struct board *board, struct board_po
ret = bile_marshall_object(board->bile, board_post_object_fields,
nboard_post_object_fields, post, &data, &size);
if (ret != 0 || size == 0) {
- warn("failed to marshall updated post object");
+ logger_printf("[board] Failed to marshall updated post object");
return;
}
if (bile_write(board->bile, BOARD_POST_RTYPE, post->id, data,
--- fidopkt.c Sat Apr 8 23:10:29 2023
+++ fidopkt.c Thu Apr 13 08:53:16 2023
@@ -522,6 +522,10 @@ fidopkt_encode_message(struct fidopkt_message *msg, ch
buf_size = FIDOPKT_HEADER_SIZE + FIDOPKT_MSG_HEADER_SIZE +
subject_len + msg->body_len + 512;
buf = xmalloczero(buf_size);
+ if (buf == NULL) {
+ logger_printf("[fidopkt] Failed allocating %ld", buf_size);
+ return 0;
+ }
tm = localtime(&msg->time);
@@ -707,6 +711,7 @@ fidopkt_encode_message(struct fidopkt_message *msg, ch
return off;
fail:
+ logger_printf("[fidopkt] Failed growing buf of size %ld", buf_size);
if (buf != NULL)
xfree(&buf);
return 0;