Skip to content

Commit 565cade

Browse files
tsailercristina-suteu
authored andcommitted
make sure the sizeof argument to calloc is the second argument.
new versions of gcc want to enforce this Signed-off-by: Thomas Sailer <[email protected]>
1 parent 8fa73f9 commit 565cade

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Diff for: libini2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ static struct ini_loop * ini_loop_new(char *buf_with_loop, char *loop_name)
469469
}
470470

471471
/* Store all necessary parameters of a loop */
472-
loop = calloc(sizeof(struct ini_loop), 1);
472+
loop = calloc(1, sizeof(struct ini_loop));
473473
if (!loop) {
474474
fprintf(stderr, "%s is %s", strerror(errno), __func__);
475475
goto err_close;

Diff for: oscplot.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -1892,7 +1892,7 @@ static PlotIioChn * plot_iio_channel_new(struct iio_context *ctx)
18921892
{
18931893
PlotIioChn *obj;
18941894

1895-
obj = calloc(sizeof(PlotIioChn), 1);
1895+
obj = calloc(1, sizeof(PlotIioChn));
18961896
if (!obj) {
18971897
fprintf(stderr, "Error in %s: %s", __func__, strerror(errno));
18981898
return NULL;
@@ -1975,7 +1975,7 @@ static PlotMathChn * plot_math_channel_new(struct iio_context *ctx)
19751975
{
19761976
PlotMathChn *obj;
19771977

1978-
obj = calloc(sizeof(PlotMathChn), 1);
1978+
obj = calloc(1, sizeof(PlotMathChn));
19791979
if (!obj) {
19801980
fprintf(stderr, "Error in %s: %s", __func__, strerror(errno));
19811981
return NULL;
@@ -2474,7 +2474,7 @@ static void update_transform_settings(OscPlot *plot, Transform *transform)
24742474
XCORR_SETTINGS(transform)->marker_type = NULL;
24752475
XCORR_SETTINGS(transform)->max_x_axis = gtk_spin_button_get_value(GTK_SPIN_BUTTON(priv->sample_count_widget));
24762476
} else if (plot_type == SPECTRUM_PLOT) {
2477-
FREQ_SPECTRUM_SETTINGS(transform)->ffts_alg_data = calloc(sizeof(struct _fft_alg_data), priv->fft_count);
2477+
FREQ_SPECTRUM_SETTINGS(transform)->ffts_alg_data = calloc(priv->fft_count, sizeof(struct _fft_alg_data));
24782478
FREQ_SPECTRUM_SETTINGS(transform)->fft_count = priv->fft_count;
24792479
FREQ_SPECTRUM_SETTINGS(transform)->freq_sweep_start = priv->start_freq + priv->filter_bw / 2;
24802480
FREQ_SPECTRUM_SETTINGS(transform)->filter_bandwidth = priv->filter_bw;
@@ -2524,35 +2524,35 @@ static Transform* add_transform_to_list(OscPlot *plot, int tr_type, GSList *chan
25242524
switch (tr_type) {
25252525
case TIME_TRANSFORM:
25262526
Transform_attach_function(transform, time_transform_function);
2527-
time_settings = (struct _time_settings *)calloc(sizeof(struct _time_settings), 1);
2527+
time_settings = (struct _time_settings *)calloc(1, sizeof(struct _time_settings));
25282528
Transform_attach_settings(transform, time_settings);
25292529
transform->graph_color = &PLOT_CHN(channels->data)->graph_color;
25302530
break;
25312531
case FFT_TRANSFORM:
25322532
Transform_attach_function(transform, fft_transform_function);
2533-
fft_settings = (struct _fft_settings *)calloc(sizeof(struct _fft_settings), 1);
2533+
fft_settings = (struct _fft_settings *)calloc(1, sizeof(struct _fft_settings));
25342534
fft_settings->window_correction = window_correction;
25352535
Transform_attach_settings(transform, fft_settings);
25362536
break;
25372537
case CONSTELLATION_TRANSFORM:
25382538
Transform_attach_function(transform, constellation_transform_function);
2539-
constellation_settings = (struct _constellation_settings *)calloc(sizeof(struct _constellation_settings), 1);
2539+
constellation_settings = (struct _constellation_settings *)calloc(1, sizeof(struct _constellation_settings));
25402540
Transform_attach_settings(transform, constellation_settings);
25412541
break;
25422542
case COMPLEX_FFT_TRANSFORM:
25432543
Transform_attach_function(transform, fft_transform_function);
2544-
fft_settings = (struct _fft_settings *)calloc(sizeof(struct _fft_settings), 1);
2544+
fft_settings = (struct _fft_settings *)calloc(1, sizeof(struct _fft_settings));
25452545
fft_settings->window_correction = window_correction;
25462546
Transform_attach_settings(transform, fft_settings);
25472547
break;
25482548
case CROSS_CORRELATION_TRANSFORM:
25492549
Transform_attach_function(transform, cross_correlation_transform_function);
2550-
xcross_settings = (struct _cross_correlation_settings *)calloc(sizeof(struct _cross_correlation_settings), 1);
2550+
xcross_settings = (struct _cross_correlation_settings *)calloc(1, sizeof(struct _cross_correlation_settings));
25512551
Transform_attach_settings(transform, xcross_settings);
25522552
break;
25532553
case FREQ_SPECTRUM_TRANSFORM:
25542554
Transform_attach_function(transform, freq_spectrum_transform_function);
2555-
freq_spectrum_settings = (struct _freq_spectrum_settings *)calloc(sizeof(struct _freq_spectrum_settings), 1);
2555+
freq_spectrum_settings = (struct _freq_spectrum_settings *)calloc(1, sizeof(struct _freq_spectrum_settings));
25562556
Transform_attach_settings(transform, freq_spectrum_settings);
25572557
break;
25582558
default:
@@ -2707,7 +2707,7 @@ static void transform_add_own_markers(OscPlot *plot, Transform *transform)
27072707
struct marker_type *markers;
27082708
int i;
27092709

2710-
markers = calloc(sizeof(struct marker_type), MAX_MARKERS + 2);
2710+
markers = calloc(MAX_MARKERS + 2, sizeof(struct marker_type));
27112711
if (!markers) {
27122712
fprintf(stderr,
27132713
"Error: could not alloc memory for markers in %s\n",

Diff for: phone_home.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static json_t * decode_url_feedback(const char *url)
202202

203203
Release * release_new(void)
204204
{
205-
return calloc(sizeof(Release), 1);
205+
return calloc(1, sizeof(Release));
206206
}
207207

208208
void release_dispose(Release *_this)

0 commit comments

Comments
 (0)