Fix sign of error return values

All RIG_E* constants should be negated when returned or compared.
Change the usages of RIG_IS_SOFT_ERRCODE() for consistency.
pull/1751/head
Daniele Forsi IU5HKX 2025-05-30 22:56:37 +02:00
rodzic 355d237ffe
commit 72bde6e131
4 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -222,10 +222,10 @@ enum rig_errcode_e {
* Soft errors are caused by invalid parameters and software/hardware features
* and cannot be fixed by retries or by re-initializing hardware.
*/
#define RIG_IS_SOFT_ERRCODE(errcode) (errcode == RIG_EINVAL || errcode == RIG_ENIMPL || errcode == RIG_ERJCTED \
|| errcode == RIG_ETRUNC || errcode == RIG_ENAVAIL || errcode == RIG_ENTARGET \
|| errcode == RIG_EVFO || errcode == RIG_EDOM || errcode == RIG_EDEPRECATED \
|| errcode == RIG_ESECURITY || errcode == RIG_EPOWER)
#define RIG_IS_SOFT_ERRCODE(errcode) (errcode == -RIG_EINVAL || errcode == -RIG_ENIMPL || errcode == -RIG_ERJCTED \
|| errcode == -RIG_ETRUNC || errcode == -RIG_ENAVAIL || errcode == -RIG_ENTARGET \
|| errcode == -RIG_EVFO || errcode == -RIG_EDOM || errcode == -RIG_EDEPRECATED \
|| errcode == -RIG_ESECURITY || errcode == -RIG_EPOWER)
/**
* \brief Token in the netrigctl protocol for returning error code

Wyświetl plik

@ -816,7 +816,7 @@ int main(int argc, char *argv[])
// if we get a hard error we try to reopen the rig again
// this should cover short dropouts that can occur
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(-retcode))
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(retcode))
{
int retry = 3;
rig_debug(RIG_DEBUG_ERR, "%s: i/o error\n", __func__);
@ -833,7 +833,7 @@ int main(int argc, char *argv[])
while (retry-- > 0 && retcode != RIG_OK);
}
}
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(-retcode)));
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(retcode)));
if (interactive && prompt)
{

Wyświetl plik

@ -1282,7 +1282,7 @@ void *handle_socket(void *arg)
// if we get a hard error we try to reopen the rig again
// this should cover short dropouts that can occur
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(-retcode))
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(retcode))
{
int retry = 3;
rig_debug(RIG_DEBUG_ERR, "%s: i/o error\n", __func__);
@ -1312,7 +1312,7 @@ void *handle_socket(void *arg)
while (!ctrl_c && !rig_opened && retry-- > 0 && retcode != RIG_OK);
}
}
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(-retcode)));
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(retcode)));
#if defined(HAVE_PTHREAD)

Wyświetl plik

@ -1283,7 +1283,7 @@ void *handle_socket(void *arg)
// if we get a hard error we try to reopen the rig again
// this should cover short dropouts that can occur
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(-retcode))
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(retcode))
{
int retry = 3;
rig_debug(RIG_DEBUG_ERR, "%s: i/o error\n", __func__);
@ -1313,7 +1313,7 @@ void *handle_socket(void *arg)
while (!ctrl_c && !rig_opened && retry-- > 0 && retcode != RIG_OK);
}
}
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(-retcode)));
while (!ctrl_c && (retcode == RIG_OK || RIG_IS_SOFT_ERRCODE(retcode)));
client_done: