mirror of https://github.com/nirenjan/libx52.git
fix: Avoid backward jumps using goto
SonarQube cloud identified a maintainability issue based on MISRA C guidelines that prohibit backward jumps. While not a mandatory fix, it helps to clean up the codebase and improves readability. Ref. MISRA C:2012, 15.2 - The goto statement shall jump to a label declared later in the same function.pull/62/head
parent
e479e338a2
commit
b6e61fc54e
|
|
@ -119,12 +119,11 @@ int x52d_client_poll(int client_fd[X52D_MAX_CLIENTS], struct pollfd pfd[MAX_CONN
|
||||||
|
|
||||||
PINELOG_TRACE("Polling %d file descriptors", pfd_count);
|
PINELOG_TRACE("Polling %d file descriptors", pfd_count);
|
||||||
|
|
||||||
retry_poll:
|
do {
|
||||||
rc = poll(pfd, pfd_count, -1);
|
rc = poll(pfd, pfd_count, -1);
|
||||||
|
} while (rc < 0 && errno == EINTR);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (errno == EINTR) {
|
|
||||||
goto retry_poll;
|
|
||||||
}
|
|
||||||
PINELOG_ERROR(_("Error %d when polling %d descriptors: %s"),
|
PINELOG_ERROR(_("Error %d when polling %d descriptors: %s"),
|
||||||
errno, pfd_count, strerror(errno));
|
errno, pfd_count, strerror(errno));
|
||||||
} else if (rc == 0) {
|
} else if (rc == 0) {
|
||||||
|
|
|
||||||
|
|
@ -73,45 +73,32 @@ static void * x52_notify_thr(void * param)
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
read_pipe_size:
|
do {
|
||||||
rc = read(notify_pipe[0], &bufsiz, sizeof(bufsiz));
|
rc = read(notify_pipe[0], &bufsiz, sizeof(bufsiz));
|
||||||
|
} while (rc < 0 && errno == EINTR);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (errno == EINTR) {
|
|
||||||
goto read_pipe_size;
|
|
||||||
} else {
|
|
||||||
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rc < 0) {
|
|
||||||
// Error condition, try again
|
// Error condition, try again
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_pipe_data:
|
do {
|
||||||
rc = read(notify_pipe[0], buffer, bufsiz);
|
rc = read(notify_pipe[0], buffer, bufsiz);
|
||||||
|
} while (rc < 0 && errno == EINTR);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (errno == EINTR) {
|
|
||||||
goto read_pipe_data;
|
|
||||||
} else {
|
|
||||||
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
}
|
// Error condition, try again
|
||||||
}
|
|
||||||
|
|
||||||
if (rc < 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < X52D_MAX_CLIENTS; i++) {
|
for (int i = 0; i < X52D_MAX_CLIENTS; i++) {
|
||||||
// Broadcast to every connected client
|
// Broadcast to every connected client
|
||||||
if (client_fd[i] != INVALID_CLIENT) {
|
if (client_fd[i] != INVALID_CLIENT) {
|
||||||
write_client_notification:
|
do {
|
||||||
rc = write(client_fd[i], buffer, bufsiz);
|
rc = write(client_fd[i], buffer, bufsiz);
|
||||||
if (rc < 0 && errno == EINTR) {
|
} while (rc < 0 && errno == EINTR);
|
||||||
goto write_client_notification;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: libx52 0.3.2\n"
|
"Project-Id-Version: libx52 0.3.2\n"
|
||||||
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
|
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
|
||||||
"POT-Creation-Date: 2026-03-09 00:47-0700\n"
|
"POT-Creation-Date: 2026-03-12 08:31-0700\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
|
@ -613,12 +613,12 @@ msgstr ""
|
||||||
msgid "Error when polling socket: FD %d, error %d, len %lu"
|
msgid "Error when polling socket: FD %d, error %d, len %lu"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: daemon/x52d_client.c:128
|
#: daemon/x52d_client.c:127
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d when polling %d descriptors: %s"
|
msgid "Error %d when polling %d descriptors: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: daemon/x52d_client.c:131
|
#: daemon/x52d_client.c:130
|
||||||
msgid "Timed out when polling"
|
msgid "Timed out when polling"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
@ -916,27 +916,27 @@ msgstr ""
|
||||||
msgid "Error setting up notification socket"
|
msgid "Error setting up notification socket"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:82 daemon/x52d_notify.c:98
|
#: daemon/x52d_notify.c:80 daemon/x52d_notify.c:90
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d reading from pipe: %s"
|
msgid "Error %d reading from pipe: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:140
|
#: daemon/x52d_notify.c:127
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d writing notification pipe: %s"
|
msgid "Error %d writing notification pipe: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:185
|
#: daemon/x52d_notify.c:172
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d creating notification pipe: %s"
|
msgid "Error %d creating notification pipe: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:194
|
#: daemon/x52d_notify.c:181
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d initializing notify thread: %s"
|
msgid "Error %d initializing notify thread: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:200
|
#: daemon/x52d_notify.c:187
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d initializing notify listener: %s"
|
msgid "Error %d initializing notify listener: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
||||||
16
po/xx_PL.po
16
po/xx_PL.po
|
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: libx52 0.2.3\n"
|
"Project-Id-Version: libx52 0.2.3\n"
|
||||||
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
|
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
|
||||||
"POT-Creation-Date: 2026-03-09 00:47-0700\n"
|
"POT-Creation-Date: 2026-03-12 08:31-0700\n"
|
||||||
"PO-Revision-Date: 2023-01-04 08:40-0800\n"
|
"PO-Revision-Date: 2023-01-04 08:40-0800\n"
|
||||||
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
|
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
|
||||||
"Language-Team: Dummy Language for testing i18n\n"
|
"Language-Team: Dummy Language for testing i18n\n"
|
||||||
|
|
@ -662,12 +662,12 @@ msgstr "Erroray arkingmay ientclay fday %d asay onblockingnay: %s"
|
||||||
msgid "Error when polling socket: FD %d, error %d, len %lu"
|
msgid "Error when polling socket: FD %d, error %d, len %lu"
|
||||||
msgstr "Erroray enwhay ollingpay ocketsay: FDay %d, erroray %d, enlay %lu"
|
msgstr "Erroray enwhay ollingpay ocketsay: FDay %d, erroray %d, enlay %lu"
|
||||||
|
|
||||||
#: daemon/x52d_client.c:128
|
#: daemon/x52d_client.c:127
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d when polling %d descriptors: %s"
|
msgid "Error %d when polling %d descriptors: %s"
|
||||||
msgstr "Erroray %d enwhay ollingpay %d escriptorsday: %s"
|
msgstr "Erroray %d enwhay ollingpay %d escriptorsday: %s"
|
||||||
|
|
||||||
#: daemon/x52d_client.c:131
|
#: daemon/x52d_client.c:130
|
||||||
msgid "Timed out when polling"
|
msgid "Timed out when polling"
|
||||||
msgstr "Imedtay outay enwhay ollingpay"
|
msgstr "Imedtay outay enwhay ollingpay"
|
||||||
|
|
||||||
|
|
@ -969,27 +969,27 @@ msgstr "Erroray isteninglay onay otificationnay ocketsay: %s"
|
||||||
msgid "Error setting up notification socket"
|
msgid "Error setting up notification socket"
|
||||||
msgstr "Erroray ettingsay upay otificationnay ocketsay: %s"
|
msgstr "Erroray ettingsay upay otificationnay ocketsay: %s"
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:82 daemon/x52d_notify.c:98
|
#: daemon/x52d_notify.c:80 daemon/x52d_notify.c:90
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d reading from pipe: %s"
|
msgid "Error %d reading from pipe: %s"
|
||||||
msgstr "Erroray eadingray omfray ipepay %d: %s"
|
msgstr "Erroray eadingray omfray ipepay %d: %s"
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:140
|
#: daemon/x52d_notify.c:127
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d writing notification pipe: %s"
|
msgid "Error %d writing notification pipe: %s"
|
||||||
msgstr "Erroray %d itingwray otificationnay ipepay: %s"
|
msgstr "Erroray %d itingwray otificationnay ipepay: %s"
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:185
|
#: daemon/x52d_notify.c:172
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d creating notification pipe: %s"
|
msgid "Error %d creating notification pipe: %s"
|
||||||
msgstr "Erroray %d eatingcray otificationnay ipepay: %s"
|
msgstr "Erroray %d eatingcray otificationnay ipepay: %s"
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:194
|
#: daemon/x52d_notify.c:181
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d initializing notify thread: %s"
|
msgid "Error %d initializing notify thread: %s"
|
||||||
msgstr "Erroray %d initializingay otifynay eadthray: %s"
|
msgstr "Erroray %d initializingay otifynay eadthray: %s"
|
||||||
|
|
||||||
#: daemon/x52d_notify.c:200
|
#: daemon/x52d_notify.c:187
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Error %d initializing notify listener: %s"
|
msgid "Error %d initializing notify listener: %s"
|
||||||
msgstr "Erroray %d initializingay otifynay istenerlay: %s"
|
msgstr "Erroray %d initializingay otifynay istenerlay: %s"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue