From: Eric Wong Date: Fri, 31 Oct 2025 02:45:00 +0000 (+0000) Subject: xap_helper: drop ugly NOT_UNUSED macro for clang X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c401587a7f02905d08c0f471f3d2a0e7bdac5081;p=thirdparty%2Fpublic-inbox.git xap_helper: drop ugly NOT_UNUSED macro for clang Using __attribute__((unused)) prevents clang warnings on variables it mistakenly warns as unused. --- diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index 511ce58ee..69ce7c7d0 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -264,9 +264,9 @@ static void xclose(int fd) EABORT("BUG: close"); } -// NOT_UNUSED keeps clang happy (tested 14.0.5 on FreeBSD) -#define NOT_UNUSED(v) (void)v -#define AUTO_UNLOCK __attribute__((__cleanup__(unlock_ensure))) +// __attribute__((__unused__)) keeps clang happy (tested 14.0.5 on FreeBSD) +#define AUTO_UNLOCK __attribute__((__cleanup__(unlock_ensure))) \ + __attribute__((__unused__)) static void unlock_ensure(void *ptr) { struct open_locks **lk_ = (struct open_locks **)ptr; @@ -337,7 +337,6 @@ static Xapian::MSet enquire_mset(struct req *req, Xapian::Enquire *enq) AUTO_UNLOCK struct open_locks *lk = lock_shared_maybe(req); req->srch->db->reopen(); // may throw - NOT_UNUSED(lk); } } return enq->get_mset(req->off, req->max); @@ -414,7 +413,6 @@ static void apply_roots_filter(struct req *req, Xapian::Query *qry) AUTO_UNLOCK struct open_locks *lk = lock_shared_maybe(req); xdb->reopen(); - NOT_UNUSED(lk); } } } @@ -719,7 +717,6 @@ static void srch_init(struct req *req) srch->qp_flags &= ~FLAG_PHRASE; srch->db->add_database(Xapian::Database(dir)); } - NOT_UNUSED(lk); break; } catch (const Xapian::Error & e) { warnx("E: Xapian::Error: %s (%s)", @@ -855,7 +852,6 @@ static void dispatch(struct req *req) srch_free(kbuf.srch); AUTO_UNLOCK struct open_locks *lk = lock_shared_maybe(req); req->srch->db->reopen(); - NOT_UNUSED(lk); } if (req->timeout_sec) alarm(req->timeout_sec > UINT_MAX ? diff --git a/lib/PublicInbox/xh_cidx.h b/lib/PublicInbox/xh_cidx.h index c725e07ad..84686dff1 100644 --- a/lib/PublicInbox/xh_cidx.h +++ b/lib/PublicInbox/xh_cidx.h @@ -89,7 +89,6 @@ static enum exc_iter dump_ibx_iter(struct req *req, const char *ibx_id, } catch (const Xapian::DatabaseModifiedError & e) { AUTO_UNLOCK struct open_locks *lk = lock_shared_maybe(req); req->srch->db->reopen(); - NOT_UNUSED(lk); return ITER_RETRY; } catch (const Xapian::DocNotFoundError & e) { // oh well... warnx("doc not found: %s", e.get_description().c_str()); @@ -235,7 +234,6 @@ static enum exc_iter dump_roots_iter(struct req *req, } catch (const Xapian::DatabaseModifiedError & e) { AUTO_UNLOCK struct open_locks *lk = lock_shared_maybe(req); req->srch->db->reopen(); - NOT_UNUSED(lk); return ITER_RETRY; } catch (const Xapian::DocNotFoundError & e) { // oh well... warnx("doc not found: %s", e.get_description().c_str()); diff --git a/lib/PublicInbox/xh_thread_fp.h b/lib/PublicInbox/xh_thread_fp.h index 9a9a6adf0..95fc5d152 100644 --- a/lib/PublicInbox/xh_thread_fp.h +++ b/lib/PublicInbox/xh_thread_fp.h @@ -21,7 +21,6 @@ static enum exc_iter xpand_col_iter(Xapian::Query *xqry, } catch (const Xapian::DatabaseModifiedError &e) { AUTO_UNLOCK struct open_locks *lk = lock_shared_maybe(cur_req); cur_req->srch->db->reopen(); - NOT_UNUSED(lk); return ITER_RETRY; } catch (const Xapian::DocNotFoundError &e) { // oh well... warnx("doc not found: %s", e.get_description().c_str());