Skip to content

Commit dbfeaf4

Browse files
Checkpoint trivial code cleanup. (#301)
Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent 633c07b commit dbfeaf4

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/qvi-rmi.cc

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
@@ -94,7 +94,7 @@ static void
9494
zsocket_close(
9595
void **sock
9696
) {
97-
if (!sock) return;
97+
if (qvi_unlikely(!sock)) return;
9898
void *isock = *sock;
9999
if (qvi_likely(isock)) {
100100
const int rc = zmq_close(isock);
@@ -109,7 +109,7 @@ static void
109109
zctx_destroy(
110110
void **ctx
111111
) {
112-
if (!ctx) return;
112+
if (qvi_unlikely(!ctx)) return;
113113
void *ictx = *ctx;
114114
if (qvi_likely(ictx)) {
115115
const int rc = zmq_ctx_destroy(ictx);
@@ -754,14 +754,15 @@ server_rpc_dispatch(
754754

755755
qvi_bbuff *res;
756756
rc = fidfunp->second(server, &hdr, body, &res);
757-
if (rc != QV_SUCCESS && rc != QV_SUCCESS_SHUTDOWN) {
757+
if (qvi_unlikely(rc != QV_SUCCESS && rc != QV_SUCCESS_SHUTDOWN)) {
758758
cstr_t ers = "RPC dispatch failed";
759759
qvi_log_error("{} with rc={} ({})", ers, rc, qv_strerr(rc));
760760
goto out;
761761
}
762762
// Shutdown?
763-
if (rc == QV_SUCCESS_SHUTDOWN) shutdown = true;
764-
763+
if (qvi_unlikely(rc == QV_SUCCESS_SHUTDOWN)) {
764+
shutdown = true;
765+
}
765766
rc = zmsg_init_from_bbuff(res, msg_out);
766767
out:
767768
zmq_msg_close(msg_in);
@@ -795,7 +796,7 @@ server_go(
795796
rc = zmsg_send(zworksock, &mtx, &bsent);
796797
if (qvi_unlikely(rc != QV_SUCCESS)) break;
797798
bsentt += bsent;
798-
} while(active);
799+
} while(qvi_likely(active));
799800
#if QVI_DEBUG_MODE == 1
800801
// Nice to understand messaging characteristics.
801802
qvi_log_debug("Server Sent {} bytes", bsentt);
@@ -885,18 +886,18 @@ qvi_rmi_server_start(
885886
) {
886887
// First populate the base hardware resource pool.
887888
int qvrc = server_populate_base_hwpool(server);
888-
if (qvrc != QV_SUCCESS) return qvrc;
889+
if (qvi_unlikely(qvrc != QV_SUCCESS)) return qvrc;
889890

890891
server->zlo = zsocket_create_and_connect(
891892
server->zctx, ZMQ_REQ, server->config.url.c_str()
892893
);
893-
if (!server->zlo) return QV_ERR_RPC;
894+
if (qvi_unlikely(!server->zlo)) return QV_ERR_RPC;
894895

895-
int rc = pthread_create(
896+
const int rc = pthread_create(
896897
&server->worker_thread, nullptr,
897898
server_start_threads, server
898899
);
899-
if (rc != 0) {
900+
if (qvi_unlikely(rc != 0)) {
900901
cstr_t ers = "pthread_create() failed";
901902
qvi_log_error("{} with rc={} ({})", ers, rc, qvi_strerr(rc));
902903
qvrc = QV_ERR_SYS;

src/qvi-utils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
@@ -71,7 +71,7 @@ void
7171
qvi_delete(
7272
T **t
7373
) {
74-
if (!t) return;
74+
if (qvi_unlikely(!t)) return;
7575
T *it = *t;
7676
if (it) {
7777
delete it;

0 commit comments

Comments
 (0)