Add return code to debug statements

Remove some RETURNFUNC that don't work with this change
pull/588/head
Michael Black W9MDB 2021-03-05 11:51:56 -06:00
rodzic 3413b3ab4e
commit c3a1b489b7
8 zmienionych plików z 42 dodań i 60 usunięć

Wyświetl plik

@ -1962,9 +1962,7 @@ static int dummy_get_trn(RIG *rig, int *trn)
static const char *dummy_get_info(RIG *rig) static const char *dummy_get_info(RIG *rig)
{ {
ENTERFUNC; return "Nothing much (dummy)";
RETURNFUNC("Nothing much (dummy)");
} }

Wyświetl plik

@ -550,7 +550,6 @@ int rig2icom_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width,
void icom2rig_mode(RIG *rig, unsigned char md, int pd, rmode_t *mode, void icom2rig_mode(RIG *rig, unsigned char md, int pd, rmode_t *mode,
pbwidth_t *width) pbwidth_t *width)
{ {
ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "%s: mode=0x%02x, pd=%d\n", __func__, md, pd); rig_debug(RIG_DEBUG_TRACE, "%s: mode=0x%02x, pd=%d\n", __func__, md, pd);
*width = RIG_PASSBAND_NORMAL; *width = RIG_PASSBAND_NORMAL;
@ -576,7 +575,7 @@ void icom2rig_mode(RIG *rig, unsigned char md, int pd, rmode_t *mode,
{ {
*mode = RIG_MODE_USB; *mode = RIG_MODE_USB;
*width = rig_passband_normal(rig, RIG_MODE_USB); *width = rig_passband_normal(rig, RIG_MODE_USB);
RETURNFUNC(); return;
} }
else if (rig->caps->rig_model == RIG_MODEL_ICR30 && pd == 0x02) else if (rig->caps->rig_model == RIG_MODEL_ICR30 && pd == 0x02)
{ {
@ -666,6 +665,5 @@ void icom2rig_mode(RIG *rig, unsigned char md, int pd, rmode_t *mode,
rig_debug(RIG_DEBUG_ERR, "icom: Unsupported Icom mode width %#.2x\n", pd); rig_debug(RIG_DEBUG_ERR, "icom: Unsupported Icom mode width %#.2x\n", pd);
} }
RETURNFUNC();
} }

Wyświetl plik

@ -1455,11 +1455,11 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode)
if (retval != RIG_OK || rfwidth.i >= RTTY_FIL_NB) if (retval != RIG_OK || rfwidth.i >= RTTY_FIL_NB)
{ {
RETURNFUNC(0); /* use default */ return(0); /* use default */
} }
else else
{ {
RETURNFUNC(rtty_fil[rfwidth.i]); return(rtty_fil[rfwidth.i]);
} }
} }
} }
@ -1471,7 +1471,7 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode)
if (priv->no_1a_03_cmd) if (priv->no_1a_03_cmd)
{ {
RETURNFUNC(0); return(0);
} }
retval = icom_transaction(rig, C_CTL_MEM, fw_sub_cmd, 0, 0, retval = icom_transaction(rig, C_CTL_MEM, fw_sub_cmd, 0, 0,
@ -1480,14 +1480,14 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode)
if (-RIG_ERJCTED == retval) if (-RIG_ERJCTED == retval)
{ {
priv->no_1a_03_cmd = -1; /* do not keep asking */ priv->no_1a_03_cmd = -1; /* do not keep asking */
RETURNFUNC(0); return(0);
} }
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: protocol error (%#.2x), " rig_debug(RIG_DEBUG_ERR, "%s: protocol error (%#.2x), "
"len=%d\n", __func__, resbuf[0], res_len); "len=%d\n", __func__, resbuf[0], res_len);
RETURNFUNC(0); /* use default */ return(0); /* use default */
} }
if (res_len == 3 && resbuf[0] == C_CTL_MEM) if (res_len == 3 && resbuf[0] == C_CTL_MEM)
@ -1497,17 +1497,17 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode)
if (mode & RIG_MODE_AM) if (mode & RIG_MODE_AM)
{ {
RETURNFUNC((i + 1) * 200); /* Ic_7800 */ return((i + 1) * 200); /* Ic_7800 */
} }
else if (mode & else if (mode &
(RIG_MODE_CW | RIG_MODE_USB | RIG_MODE_LSB | RIG_MODE_RTTY | (RIG_MODE_CW | RIG_MODE_USB | RIG_MODE_LSB | RIG_MODE_RTTY |
RIG_MODE_RTTYR)) RIG_MODE_RTTYR))
{ {
RETURNFUNC(i < 10 ? (i + 1) * 50 : (i - 4) * 100); return(i < 10 ? (i + 1) * 50 : (i - 4) * 100);
} }
} }
RETURNFUNC(0); return(0);
} }
int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width)

Wyświetl plik

@ -1001,8 +1001,8 @@ static int kenwood_get_if(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
RETURNFUNC(kenwood_safe_transaction(rig, "IF", priv->info, return(kenwood_safe_transaction(rig, "IF", priv->info,
KENWOOD_MAX_BUF_LEN, caps->if_len);); KENWOOD_MAX_BUF_LEN, caps->if_len));
} }
@ -4572,25 +4572,25 @@ const char *kenwood_get_info(RIG *rig)
if (!rig) if (!rig)
{ {
RETURNFUNC("*rig == NULL"); return("*rig == NULL");
} }
retval = kenwood_safe_transaction(rig, "TY", firmbuf, 10, 5); retval = kenwood_safe_transaction(rig, "TY", firmbuf, 10, 5);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
RETURNFUNC(NULL); return(NULL);
} }
switch (firmbuf[4]) switch (firmbuf[4])
{ {
case '0': RETURNFUNC("Firmware: Overseas type"); case '0': return("Firmware: Overseas type");
case '1': RETURNFUNC("Firmware: Japanese 100W type"); case '1': return("Firmware: Japanese 100W type");
case '2': RETURNFUNC("Firmware: Japanese 20W type"); case '2': return("Firmware: Japanese 20W type");
default: RETURNFUNC("Firmware: unknown"); default: return("Firmware: unknown");
} }
} }

Wyświetl plik

@ -143,7 +143,7 @@ void errmsg(int err, char *s, const char *func, const char *file, int line);
#define ERRMSG(err, s) errmsg(err, s, __func__, __FILENAME__, __LINE__) #define ERRMSG(err, s) errmsg(err, s, __func__, __FILENAME__, __LINE__)
#define ENTERFUNC rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s entered\n", __FILENAME__, __LINE__, __func__) #define ENTERFUNC rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s entered\n", __FILENAME__, __LINE__, __func__)
#define RETURNFUNC(rc) do { \ #define RETURNFUNC(rc) do { \
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s return\n", __FILENAME__, __LINE__, __func__); \ rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s return(%ld)\n", __FILENAME__, __LINE__, __func__, (long int) rc); \
return rc; \ return rc; \
} while(0) } while(0)

Wyświetl plik

@ -4804,16 +4804,14 @@ int HAMLIB_API rig_mW2power(RIG *rig,
{ {
const freq_range_t *txrange; const freq_range_t *txrange;
ENTERFUNC;
if (!rig || !rig->caps || !power || mwpower == 0) if (!rig || !rig->caps || !power || mwpower == 0)
{ {
RETURNFUNC(-RIG_EINVAL); return(-RIG_EINVAL);
} }
if (rig->caps->mW2power != NULL) if (rig->caps->mW2power != NULL)
{ {
RETURNFUNC(rig->caps->mW2power(rig, power, mwpower, freq, mode)); return(rig->caps->mW2power(rig, power, mwpower, freq, mode));
} }
txrange = rig_get_range(rig->state.tx_range_list, freq, mode); txrange = rig_get_range(rig->state.tx_range_list, freq, mode);
@ -4823,13 +4821,13 @@ int HAMLIB_API rig_mW2power(RIG *rig,
/* /*
* freq is not on the tx range! * freq is not on the tx range!
*/ */
RETURNFUNC(-RIG_ECONF); /* could be RIG_EINVAL ? */ return(-RIG_ECONF); /* could be RIG_EINVAL ? */
} }
if (txrange->high_power == 0) if (txrange->high_power == 0)
{ {
*power = 0.0; *power = 0.0;
RETURNFUNC(RIG_OK); return(RIG_OK);
} }
*power = (float)mwpower / txrange->high_power; *power = (float)mwpower / txrange->high_power;
@ -4839,7 +4837,7 @@ int HAMLIB_API rig_mW2power(RIG *rig,
*power = 1.0; *power = 1.0;
} }
RETURNFUNC(mwpower > txrange->high_power ? RIG_OK : -RIG_ETRUNC); return(mwpower > txrange->high_power ? RIG_OK : -RIG_ETRUNC);
} }

Wyświetl plik

@ -884,18 +884,16 @@ int HAMLIB_API ser_get_rts(hamlib_port_t *p, int *state)
int retcode; int retcode;
unsigned int y; unsigned int y;
ENTERFUNC;
// cannot do this for microHam ports // cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd) if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{ {
RETURNFUNC(-RIG_ENIMPL); return(-RIG_ENIMPL);
} }
retcode = IOCTL(p->fd, TIOCMGET, &y); retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_RTS) == TIOCM_RTS; *state = (y & TIOCM_RTS) == TIOCM_RTS;
RETURNFUNC(retcode < 0 ? -RIG_EIO : RIG_OK); return(retcode < 0 ? -RIG_EIO : RIG_OK);
} }
@ -971,24 +969,22 @@ int HAMLIB_API ser_get_dtr(hamlib_port_t *p, int *state)
int retcode; int retcode;
unsigned int y; unsigned int y;
ENTERFUNC;
// cannot do this for the RADIO port, return PTT state for the PTT port // cannot do this for the RADIO port, return PTT state for the PTT port
if (p->fd == uh_ptt_fd) if (p->fd == uh_ptt_fd)
{ {
*state = uh_get_ptt(); *state = uh_get_ptt();
RETURNFUNC(RIG_OK); return(RIG_OK);
} }
if (p->fd == uh_radio_fd) if (p->fd == uh_radio_fd)
{ {
RETURNFUNC(-RIG_ENIMPL); return(-RIG_ENIMPL);
} }
retcode = IOCTL(p->fd, TIOCMGET, &y); retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_DTR) == TIOCM_DTR; *state = (y & TIOCM_DTR) == TIOCM_DTR;
RETURNFUNC(retcode < 0 ? -RIG_EIO : RIG_OK); return(retcode < 0 ? -RIG_EIO : RIG_OK);
} }
@ -1000,19 +996,17 @@ int HAMLIB_API ser_get_dtr(hamlib_port_t *p, int *state)
*/ */
int HAMLIB_API ser_set_brk(hamlib_port_t *p, int state) int HAMLIB_API ser_set_brk(hamlib_port_t *p, int state)
{ {
ENTERFUNC;
// ignore this for microHam ports // ignore this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd) if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{ {
RETURNFUNC(RIG_OK); return(RIG_OK);
} }
#if defined(TIOCSBRK) && defined(TIOCCBRK) #if defined(TIOCSBRK) && defined(TIOCCBRK)
RETURNFUNC(IOCTL(p->fd, state ? TIOCSBRK : TIOCCBRK, 0) < 0 ? return(IOCTL(p->fd, state ? TIOCSBRK : TIOCCBRK, 0) < 0 ?
-RIG_EIO : RIG_OK;); -RIG_EIO : RIG_OK);
#else #else
RETURNFUNC(-RIG_ENIMPL); return(-RIG_ENIMPL);
#endif #endif
} }
@ -1027,18 +1021,16 @@ int HAMLIB_API ser_get_car(hamlib_port_t *p, int *state)
int retcode; int retcode;
unsigned int y; unsigned int y;
ENTERFUNC;
// cannot do this for microHam ports // cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd) if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{ {
RETURNFUNC(-RIG_ENIMPL); return(-RIG_ENIMPL);
} }
retcode = IOCTL(p->fd, TIOCMGET, &y); retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_CAR) == TIOCM_CAR; *state = (y & TIOCM_CAR) == TIOCM_CAR;
RETURNFUNC(retcode < 0 ? -RIG_EIO : RIG_OK); return(retcode < 0 ? -RIG_EIO : RIG_OK);
} }
@ -1052,18 +1044,16 @@ int HAMLIB_API ser_get_cts(hamlib_port_t *p, int *state)
int retcode; int retcode;
unsigned int y; unsigned int y;
ENTERFUNC;
// cannot do this for microHam ports // cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd) if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{ {
RETURNFUNC(-RIG_ENIMPL); return(-RIG_ENIMPL);
} }
retcode = IOCTL(p->fd, TIOCMGET, &y); retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_CTS) == TIOCM_CTS; *state = (y & TIOCM_CTS) == TIOCM_CTS;
RETURNFUNC(retcode < 0 ? -RIG_EIO : RIG_OK); return(retcode < 0 ? -RIG_EIO : RIG_OK);
} }
@ -1077,18 +1067,16 @@ int HAMLIB_API ser_get_dsr(hamlib_port_t *p, int *state)
int retcode; int retcode;
unsigned int y; unsigned int y;
ENTERFUNC;
// cannot do this for microHam ports // cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd) if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{ {
RETURNFUNC(-RIG_ENIMPL); return(-RIG_ENIMPL);
} }
retcode = IOCTL(p->fd, TIOCMGET, &y); retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_DSR) == TIOCM_DSR; *state = (y & TIOCM_DSR) == TIOCM_DSR;
RETURNFUNC(retcode < 0 ? -RIG_EIO : RIG_OK); return(retcode < 0 ? -RIG_EIO : RIG_OK);
} }
/** @} */ /** @} */

Wyświetl plik

@ -95,9 +95,9 @@ int main()
{ {
printf("%s\n", buf); printf("%s\n", buf);
usleep(50 * 1000); usleep(50 * 1000);
// int id = NC_RIGID_FTDX101D; int id = NC_RIGID_FTDX101D;
int id = NC_RIGID_FTDX3000; // int id = NC_RIGID_FTDX3000;
n = fprintf(fp, "ID%03d", id); n = fprintf(fp, "ID%03d;", id);
printf("n=%d\n", n); printf("n=%d\n", n);
if (n <= 0) { perror("ID"); } if (n <= 0) { perror("ID"); }