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);
|
||||
|
||||
retry_poll:
|
||||
rc = poll(pfd, pfd_count, -1);
|
||||
do {
|
||||
rc = poll(pfd, pfd_count, -1);
|
||||
} while (rc < 0 && errno == EINTR);
|
||||
|
||||
if (rc < 0) {
|
||||
if (errno == EINTR) {
|
||||
goto retry_poll;
|
||||
}
|
||||
PINELOG_ERROR(_("Error %d when polling %d descriptors: %s"),
|
||||
errno, pfd_count, strerror(errno));
|
||||
} else if (rc == 0) {
|
||||
|
|
|
|||
|
|
@ -73,45 +73,32 @@ static void * x52_notify_thr(void * param)
|
|||
int rc;
|
||||
|
||||
for (;;) {
|
||||
read_pipe_size:
|
||||
rc = read(notify_pipe[0], &bufsiz, sizeof(bufsiz));
|
||||
if (rc < 0) {
|
||||
if (errno == EINTR) {
|
||||
goto read_pipe_size;
|
||||
} else {
|
||||
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
||||
errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
rc = read(notify_pipe[0], &bufsiz, sizeof(bufsiz));
|
||||
} while (rc < 0 && errno == EINTR);
|
||||
if (rc < 0) {
|
||||
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
||||
errno, strerror(errno));
|
||||
// Error condition, try again
|
||||
continue;
|
||||
}
|
||||
|
||||
read_pipe_data:
|
||||
rc = read(notify_pipe[0], buffer, bufsiz);
|
||||
if (rc < 0) {
|
||||
if (errno == EINTR) {
|
||||
goto read_pipe_data;
|
||||
} else {
|
||||
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
||||
errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
rc = read(notify_pipe[0], buffer, bufsiz);
|
||||
} while (rc < 0 && errno == EINTR);
|
||||
if (rc < 0) {
|
||||
PINELOG_ERROR(_("Error %d reading from pipe: %s"),
|
||||
errno, strerror(errno));
|
||||
// Error condition, try again
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < X52D_MAX_CLIENTS; i++) {
|
||||
// Broadcast to every connected client
|
||||
if (client_fd[i] != INVALID_CLIENT) {
|
||||
write_client_notification:
|
||||
rc = write(client_fd[i], buffer, bufsiz);
|
||||
if (rc < 0 && errno == EINTR) {
|
||||
goto write_client_notification;
|
||||
}
|
||||
do {
|
||||
rc = write(client_fd[i], buffer, bufsiz);
|
||||
} while (rc < 0 && errno == EINTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: libx52 0.3.2\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"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -613,12 +613,12 @@ msgstr ""
|
|||
msgid "Error when polling socket: FD %d, error %d, len %lu"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_client.c:128
|
||||
#: daemon/x52d_client.c:127
|
||||
#, c-format
|
||||
msgid "Error %d when polling %d descriptors: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_client.c:131
|
||||
#: daemon/x52d_client.c:130
|
||||
msgid "Timed out when polling"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -916,27 +916,27 @@ msgstr ""
|
|||
msgid "Error setting up notification socket"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_notify.c:82 daemon/x52d_notify.c:98
|
||||
#: daemon/x52d_notify.c:80 daemon/x52d_notify.c:90
|
||||
#, c-format
|
||||
msgid "Error %d reading from pipe: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_notify.c:140
|
||||
#: daemon/x52d_notify.c:127
|
||||
#, c-format
|
||||
msgid "Error %d writing notification pipe: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_notify.c:185
|
||||
#: daemon/x52d_notify.c:172
|
||||
#, c-format
|
||||
msgid "Error %d creating notification pipe: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_notify.c:194
|
||||
#: daemon/x52d_notify.c:181
|
||||
#, c-format
|
||||
msgid "Error %d initializing notify thread: %s"
|
||||
msgstr ""
|
||||
|
||||
#: daemon/x52d_notify.c:200
|
||||
#: daemon/x52d_notify.c:187
|
||||
#, c-format
|
||||
msgid "Error %d initializing notify listener: %s"
|
||||
msgstr ""
|
||||
|
|
|
|||
16
po/xx_PL.po
16
po/xx_PL.po
|
|
@ -7,7 +7,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: libx52 0.2.3\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"
|
||||
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\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"
|
||||
msgstr "Erroray enwhay ollingpay ocketsay: FDay %d, erroray %d, enlay %lu"
|
||||
|
||||
#: daemon/x52d_client.c:128
|
||||
#: daemon/x52d_client.c:127
|
||||
#, c-format
|
||||
msgid "Error %d when polling %d descriptors: %s"
|
||||
msgstr "Erroray %d enwhay ollingpay %d escriptorsday: %s"
|
||||
|
||||
#: daemon/x52d_client.c:131
|
||||
#: daemon/x52d_client.c:130
|
||||
msgid "Timed out when polling"
|
||||
msgstr "Imedtay outay enwhay ollingpay"
|
||||
|
||||
|
|
@ -969,27 +969,27 @@ msgstr "Erroray isteninglay onay otificationnay ocketsay: %s"
|
|||
msgid "Error setting up notification socket"
|
||||
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
|
||||
msgid "Error %d reading from pipe: %s"
|
||||
msgstr "Erroray eadingray omfray ipepay %d: %s"
|
||||
|
||||
#: daemon/x52d_notify.c:140
|
||||
#: daemon/x52d_notify.c:127
|
||||
#, c-format
|
||||
msgid "Error %d writing notification pipe: %s"
|
||||
msgstr "Erroray %d itingwray otificationnay ipepay: %s"
|
||||
|
||||
#: daemon/x52d_notify.c:185
|
||||
#: daemon/x52d_notify.c:172
|
||||
#, c-format
|
||||
msgid "Error %d creating notification pipe: %s"
|
||||
msgstr "Erroray %d eatingcray otificationnay ipepay: %s"
|
||||
|
||||
#: daemon/x52d_notify.c:194
|
||||
#: daemon/x52d_notify.c:181
|
||||
#, c-format
|
||||
msgid "Error %d initializing notify thread: %s"
|
||||
msgstr "Erroray %d initializingay otifynay eadthray: %s"
|
||||
|
||||
#: daemon/x52d_notify.c:200
|
||||
#: daemon/x52d_notify.c:187
|
||||
#, c-format
|
||||
msgid "Error %d initializing notify listener: %s"
|
||||
msgstr "Erroray %d initializingay otifynay istenerlay: %s"
|
||||
|
|
|
|||
Loading…
Reference in New Issue