Quiet a few more cppcheck gripes.

Making these functions static also reduces the possibilities of
 collisions with app names and may shorten load time.
And I can finally make meter_type1 and meter_type2 const, like I
 tried to do in the beginning.
pull/1749/head
George Baltz N3GB 2025-05-28 14:26:34 -04:00
rodzic 00d285576c
commit b74bd31b40
9 zmienionych plików z 22 dodań i 21 usunięć

1
.gitignore vendored
Wyświetl plik

@ -21,6 +21,7 @@ config.sub
config.log
config.status
configure
cppcheck.log
depcomp
hamlib.pc
hamlib.spec

Wyświetl plik

@ -2312,7 +2312,7 @@ static int dummy_mW2power(RIG *rig, float *power, unsigned int mwpower,
static int m_year, m_month, m_day, m_hour, m_min, m_sec, m_utc_offset;
static double m_msec;
int dummy_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
static int dummy_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
int sec, double msec, int utc_offset)
{
int retval = RIG_OK;
@ -2337,7 +2337,7 @@ int dummy_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
return retval;
}
int dummy_get_clock(RIG *rig, int *year, int *month, int *day, int *hour,
static int dummy_get_clock(RIG *rig, int *year, int *month, int *day, int *hour,
int *min, int *sec, double *msec, int *utc_offset)
{
int retval = RIG_OK;

Wyświetl plik

@ -439,7 +439,7 @@ int dttsp_set_conf(RIG *rig, hamlib_token_t token, const char *val)
* Assumes rig!=NULL, STATE(rig)->priv!=NULL
* and val points to a buffer big enough to hold the conf value.
*/
int dttsp_get_conf2(RIG *rig, hamlib_token_t token, char *val, int val_len)
static int dttsp_get_conf2(RIG *rig, hamlib_token_t token, char *val, int val_len)
{
struct dttsp_priv_data *priv;
struct rig_state *rs;

Wyświetl plik

@ -211,7 +211,7 @@ static const struct icom_priv_caps ic7100_priv_caps =
};
// if hour < 0 then only date will be set
int ic7100_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
static int ic7100_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
int sec, double msec, int utc_offset)
{
int cmd = 0x1a;
@ -265,7 +265,7 @@ int ic7100_set_clock(RIG *rig, int year, int month, int day, int hour, int min,
return retval;
}
int ic7100_get_clock(RIG *rig, int *year, int *month, int *day, int *hour,
static int ic7100_get_clock(RIG *rig, int *year, int *month, int *day, int *hour,
int *min, int *sec, double *msec, int *utc_offset)
{
int cmd = 0x1a;

Wyświetl plik

@ -95,8 +95,8 @@
} }
int ic7200_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
int ic7200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
static int ic7200_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
static int ic7200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
/*
* IC-7200 rig capabilities.
@ -295,7 +295,7 @@ struct rig_caps ic7200_caps =
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
};
int ic7200_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
static int ic7200_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
unsigned char cmdbuf[MAXFRAMELEN];
@ -312,7 +312,7 @@ int ic7200_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
}
int ic7200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
static int ic7200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
unsigned char cmdbuf[MAXFRAMELEN];

Wyświetl plik

@ -290,13 +290,13 @@ static int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level,
case RIG_LEVEL_STRENGTH:
case RIG_LEVEL_RFPOWER_METER_WATTS:
{
cal_table_float_t *table;
const cal_table_float_t *table;
ptt_t ptt = RIG_PTT_OFF;
/* Values taken from the TS-890S In-Depth Manual (IDM), p. 8
* 0.03 - 21.5 MHz, Preamp 1
*/
/* Meter Type 1 - Kenwood specific, factory default */
static cal_table_float_t meter_type1 =
static const cal_table_float_t meter_type1 =
{
9, { { 0, -28.4f}, { 3, -26}, {11, -19.5f},
{19, -13}, {27, -6.5f}, {35, 0},
@ -304,7 +304,7 @@ static int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level,
}
};
/* Meter Type 2 - IARU recommended */
static cal_table_float_t meter_type2 =
static const cal_table_float_t meter_type2 =
{
9, { { 0, -54}, { 3, -48}, {11, -36},
{19, -24}, {27, -12}, {35, 0},
@ -462,7 +462,7 @@ static int ts890_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
return retval;
}
*status = current[2] & mask ? 1 : 0;
*status = (current[2] & mask) ? 1 : 0;
return RIG_OK;
}

Wyświetl plik

@ -144,7 +144,7 @@ int ftdx3000_ext_tokens[] =
TOK_BACKEND_NONE
};
int ft3000_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
static int ft3000_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
{
char *cmd;
int err;
@ -181,7 +181,7 @@ int ft3000_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
RETURNFUNC(RIG_OK);
}
int ft3000_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
static int ft3000_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx)
{
struct newcat_priv_data *priv = (struct newcat_priv_data *)STATE(rig)->priv;

Wyświetl plik

@ -333,7 +333,7 @@ struct rig_caps pmr171_caps =
//*****************************************************/
#include <stdint.h>
uint16_t CRC16Check(const unsigned char *buf, int len)
static uint16_t CRC16Check(const unsigned char *buf, int len)
{
uint16_t crc = 0xFFFF; // Initial value
uint16_t polynomial = 0x1021; // Polynomial x^16 + x^12 + x^5 + 1
@ -479,7 +479,7 @@ rmode_t pmr171_modes[GUOHE_MODE_TABLE_MAX] =
RIG_MODE_RTTY // not functioning
};
rmode_t guohe2rmode(unsigned char mode, const rmode_t mode_table[])
static rmode_t guohe2rmode(unsigned char mode, const rmode_t mode_table[])
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called, mode=0x%02x\n", __func__,
mode);
@ -494,7 +494,7 @@ rmode_t guohe2rmode(unsigned char mode, const rmode_t mode_table[])
return (mode_table[mode]);
}
unsigned char rmode2guohe(rmode_t mode, const rmode_t mode_table[])
static unsigned char rmode2guohe(rmode_t mode, const rmode_t mode_table[])
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called, mode=%s\n", __func__,
rig_strrmode(mode));
@ -519,7 +519,7 @@ unsigned char rmode2guohe(rmode_t mode, const rmode_t mode_table[])
/**
* Converting to Big-endian bytes
*/
unsigned char *to_be(unsigned char data[],
static unsigned char *to_be(unsigned char data[],
unsigned long long freq,
unsigned int byte_len)
{
@ -538,7 +538,7 @@ unsigned char *to_be(unsigned char data[],
}
unsigned long long from_be(const unsigned char data[],
static unsigned long long from_be(const unsigned char data[],
unsigned int byte_len)
{
int i;

Wyświetl plik

@ -40,7 +40,7 @@
// just doing a warning message for now
// eventually should make this -RIG_EINTERNAL
int check_buffer_overflow(char *str, int len, int nlen)
static int check_buffer_overflow(char *str, int len, int nlen)
{
if (len + 32 >= nlen) // make sure at least 32 bytes are available
{