jcs
/subtext
/amendments
/605
board: Fix strncmp return checking
jcs made amendment 605 10 months ago
--- board.c Mon May 20 14:36:47 2024
+++ board.c Sat Dec 6 17:44:46 2025
@@ -745,8 +745,8 @@ post_compose_start:
session_flush(s);
} else if (ftn_parent_post) {
session_printf(s, "{{B}}Subject:{{/B}}{{#}} %s%s\r\n",
- strncmp("Re:", ftn_parent_post->subject, 3) == 1 ?
- "" : "Re: ", ftn_parent_post->subject);
+ strncmp(ftn_parent_post->subject, "Re:", 3) == 0 ? "" : "Re: ",
+ ftn_parent_post->subject);
session_flush(s);
} else {
if (initial_subject && !thread->subject) {
@@ -1222,8 +1222,7 @@ board_post_create(struct board *board, struct board_th
if (ftn_parent_post) {
snprintf(ftn_post.subject, sizeof(ftn_post.subject),
"%s%s",
- strncmp("Re:", ftn_parent_post->subject, 3) == 1 ?
- "" : "Re: ",
+ strncmp(ftn_parent_post->subject, "Re:", 3) == 0 ? "" : "Re: ",
ftn_parent_post->subject);
strlcpy(ftn_post.reply, ftn_parent_post->msgid_orig,
sizeof(ftn_post.reply));
@@ -1325,11 +1324,11 @@ board_post_create(struct board *board, struct board_th
sizeof(long));
if (post_ids == NULL)
return 0;
- thread->post_ids = post_ids;
parent_post_ids = xreallocarray(thread->parent_post_ids,
thread->nposts, sizeof(long));
if (parent_post_ids == NULL)
return 0;
+ thread->post_ids = post_ids;
thread->parent_post_ids = parent_post_ids;
/*
@@ -1768,11 +1767,14 @@ board_toss_ftn_message(struct board *board,
} else {
npost_ids = bile_ids_by_type(board->bile, BOARD_FTN_POST_RTYPE,
&post_ids);
+ if (npost_ids == 0)
+ goto add;
msgid_cache = xcalloc(sizeof(struct board_ftn_msgid_cache),
npost_ids + 1);
if (msgid_cache == NULL) {
logger_printf("[board] toss: calloc(%ld, %ld) failed",
sizeof(struct board_ftn_msgid_cache), npost_ids + 1);
+ xfree(&post_ids);
return -1;
}
for (n = 0; n < npost_ids; n++) {
@@ -1786,14 +1788,15 @@ board_toss_ftn_message(struct board *board,
sizeof(post.msgid));
}
dirty_cache = true;
+ xfree(&post_ids);
}
-
+
+add:
uthread_yield();
if (!local) {
for (n = 0; n < npost_ids; n++) {
- if (memcmp(&msgid_cache[n].msgid, &msgid,
- sizeof(msgid)) == 0) {
+ if (memcmp(&msgid_cache[n].msgid, &msgid, sizeof(msgid)) == 0) {
logger_printf("[board] Already have %s EchoMail %s in %s "
"(%ld), skipping", db->config.ftn_network,
fidomsg->msgid_orig, board->name, msgid_cache[n].id);