mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-21 10:27:18 +00:00
Fix CodeQL warnings
This commit is contained in:
parent
014bc04ddf
commit
0a0873252e
@ -691,7 +691,7 @@ int ft757_get_update_data(RIG *rig)
|
||||
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x10};
|
||||
struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv;
|
||||
int retval = 0;
|
||||
int nbtries ;
|
||||
long nbtries;
|
||||
/* Maximum number of attempts to ask/read the data. */
|
||||
int maxtries = rig->state.rigport.retry ;
|
||||
|
||||
@ -723,7 +723,7 @@ int ft757_get_update_data(RIG *rig)
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: read update_data failed, %d octets of %d read, retry %d out of %d\n",
|
||||
"%s: read update_data failed, %d octets of %d read, retry %ld out of %d\n",
|
||||
__func__, retval, FT757GX_STATUS_UPDATE_DATA_LENGTH,
|
||||
nbtries, maxtries);
|
||||
/* The delay is quadratic. */
|
||||
|
@ -2236,7 +2236,7 @@ int newcat_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *offs)
|
||||
/* chop term */
|
||||
priv->ret_data[ret_data_len - 1] = '\0';
|
||||
|
||||
*offs = atoi(retoffs) * step;
|
||||
*offs = atol(retoffs) * step;
|
||||
|
||||
RETURNFUNC(RIG_OK);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ if100_set_position(ROT *rot, azimuth_t az, elevation_t el)
|
||||
int az_i;
|
||||
int el_i;
|
||||
int dataout, i;
|
||||
float az_scale, el_scale;
|
||||
double az_scale, el_scale;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el);
|
||||
|
||||
|
@ -2351,8 +2351,9 @@ char *date_strget(char *buf, int buflen)
|
||||
struct tm *mytm;
|
||||
time_t t;
|
||||
struct timeval tv;
|
||||
struct tm result;
|
||||
t = time(NULL);
|
||||
mytm = gmtime(&t);
|
||||
mytm = gmtime_r(&t, &result);
|
||||
strftime(buf, buflen, "%Y-%m-%d:%H:%M:%S.", mytm);
|
||||
gettimeofday(&tv, NULL);
|
||||
sprintf(tmp, "%06ld", (long)tv.tv_usec);
|
||||
|
@ -729,7 +729,7 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status)
|
||||
|
||||
int rig_sprintf_spectrum_modes(char *str, int nlen, const enum rig_spectrum_mode_e *modes)
|
||||
{
|
||||
int i, len = 0;
|
||||
int i, len = 0, lentmp;
|
||||
|
||||
*str = '\0';
|
||||
|
||||
@ -749,16 +749,22 @@ int rig_sprintf_spectrum_modes(char *str, int nlen, const enum rig_spectrum_mode
|
||||
break;
|
||||
}
|
||||
|
||||
len += snprintf(str + len, nlen - len, "%d=%s ", modes[i], sm);
|
||||
lentmp = snprintf(str + len, nlen - len, "%d=%s ", modes[i], sm);
|
||||
if (len < 0 || lentmp >= nlen - len)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,"%s(%d): overflowed str buffer\n", __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
len += lentmp;
|
||||
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
return len;
|
||||
}
|
||||
|
||||
int rig_sprintf_spectrum_spans(char *str, int nlen, const freq_t *spans)
|
||||
{
|
||||
int i, len = 0;
|
||||
int i, len = 0, lentmp;
|
||||
|
||||
*str = '\0';
|
||||
|
||||
@ -769,16 +775,21 @@ int rig_sprintf_spectrum_spans(char *str, int nlen, const freq_t *spans)
|
||||
break;
|
||||
}
|
||||
|
||||
len += snprintf(str + len, nlen - len, "%.0f ", spans[i]);
|
||||
lentmp = snprintf(str + len, nlen - len, "%.0f ", spans[i]);
|
||||
if (len < 0 || lentmp >= nlen - len)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,"%s(%d): overflowed str buffer\n", __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
len += lentmp;
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
return len;
|
||||
}
|
||||
|
||||
int rig_sprintf_spectrum_avg_modes(char *str, int nlen, const struct rig_spectrum_avg_mode *avg_modes)
|
||||
{
|
||||
int i, len = 0;
|
||||
int i, len = 0, lentmp;
|
||||
|
||||
*str = '\0';
|
||||
|
||||
@ -789,10 +800,15 @@ int rig_sprintf_spectrum_avg_modes(char *str, int nlen, const struct rig_spectru
|
||||
break;
|
||||
}
|
||||
|
||||
len += snprintf(str + len, nlen - len, "%d=\"%s\" ", avg_modes[i].id, avg_modes[i].name);
|
||||
lentmp = snprintf(str + len, nlen - len, "%d=\"%s\" ", avg_modes[i].id, avg_modes[i].name);
|
||||
if (len < 0 || lentmp >= nlen - len)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,"%s(%d): overflowed str buffer\n", __FILE__, __LINE__);
|
||||
break;
|
||||
}
|
||||
len += lentmp;
|
||||
}
|
||||
|
||||
check_buffer_overflow(str, len, nlen);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user