Skip to content

Commit 7cb82f0

Browse files
committed
Cleanup, added voids to functions without parameters, removed unused variables.
1 parent d4b2fa1 commit 7cb82f0

20 files changed

+49
-54
lines changed

gitwatcher/git.c.in

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88
#define FALSE 0
99
#endif
1010

11-
int git_populated() {
11+
int git_populated(void) {
1212
return @GIT_RETRIEVED_STATE@;
1313
}
1414

15-
int git_dirty() {
15+
int git_dirty(void) {
1616
return @GIT_IS_DIRTY@;
1717
}
1818

19-
const char *git_commit_sha1() {
19+
const char *git_commit_sha1(void) {
2020
return "@GIT_HEAD_SHA1@";
2121
}
2222

23-
const char *git_commit_date() {
23+
const char *git_commit_date(void) {
2424
return "@GIT_COMMIT_DATE_ISO8601@";
2525
}
2626

27-
const char *git_describe() {
27+
const char *git_describe(void) {
2828
return "@GIT_DESCRIBE@";
2929
}
3030

31-
const char *git_branch() {
31+
const char *git_branch(void) {
3232
return "@GIT_BRANCH@";
3333
}
3434

gitwatcher/git.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef JABS_GIT_H
22
#define JABS_GIT_H
33

4-
int git_populated();
5-
int git_dirty();
6-
const char *git_commit_sha1();
7-
const char *git_commit_date();
8-
const char *git_describe();
9-
const char *git_branch();
4+
int git_populated(void);
5+
int git_dirty(void);
6+
const char *git_commit_sha1(void);
7+
const char *git_commit_date(void);
8+
const char *git_describe(void);
9+
const char *git_branch(void);
1010
#endif //JABS_GIT_H

src/aperture.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void aperture_free(aperture *a) {
1515
free(a);
1616
}
1717

18-
aperture *aperture_default() {
18+
aperture *aperture_default(void) {
1919
aperture *a = malloc(sizeof(aperture));
2020
a->type = APERTURE_NONE;
2121
a->width = 0.0;

src/aperture.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct aperture {
4242
} aperture;
4343

4444
const char *aperture_name(const aperture *a);
45-
aperture *aperture_default();
45+
aperture *aperture_default(void);
4646
aperture *aperture_clone(const aperture *a_orig);
4747
void aperture_free(aperture *a);
4848
double aperture_width_shape_product(const aperture *a, char direction);

src/brick.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ void bricks_convolute(jabs_histogram *h, const calibration *c, const brick *bric
3535
continue;
3636
}
3737
const brick *b_high = &bricks[i-1];
38-
double E_high, E_low, E_cutoff_low, E_cutoff_high; /* Lower energy edge of brick, Low energy cutoff (gaussian), High energy cutoff (gaussian) */
38+
double E_cutoff_low, E_cutoff_high; /* Low energy cutoff (gaussian), High energy cutoff (gaussian) */
3939
if(b_low->E < b_high->E) { /* Detected energy increasing as brick number increases */
40-
E_low = b_low->E;
41-
E_high = b_high->E;
4240
E_cutoff_low = b_low->E - b_low->S_sum * sigmas_cutoff;
4341
E_cutoff_high = b_high->E + b_high->S_sum * sigmas_cutoff;
4442
} else { /* Energy decreasing as brick number increases */
45-
E_low = b_high->E;
46-
E_high = b_low->E;
4743
E_cutoff_low = b_high->E - b_high->S_sum * sigmas_cutoff;
4844
E_cutoff_high = b_low->E + b_low->S_sum * sigmas_cutoff;
4945
}

src/calibration.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
extern inline double calibration_eval(const calibration *c, size_t ch);
1414

15-
calibration *calibration_init() {
15+
calibration *calibration_init(void) {
1616
calibration *c = calloc(1, sizeof(calibration));
1717
if(!c)
1818
return NULL;
@@ -53,7 +53,7 @@ void calibration_free(calibration *c) {
5353
free(c);
5454
}
5555

56-
calibration *calibration_init_linear() {
56+
calibration *calibration_init_linear(void) {
5757
calibration *c = calibration_init();
5858
if(!c)
5959
return NULL;

src/calibration.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ typedef struct calibration_params_poly {
5959
double *a; /* Array, size n+1, polynomial is f(x) = a[0] + a[1] * x + a[2] * x^2 + ... + a[n] * x^n */
6060
} calibration_params_poly;
6161

62-
calibration *calibration_init();
62+
calibration *calibration_init(void);
6363
void calibration_free(calibration *c);
6464
calibration *calibration_clone(const calibration *c_orig);
65-
calibration *calibration_init_linear();
65+
calibration *calibration_init_linear(void);
6666
calibration *calibration_init_poly(size_t n); /* n is the degree of the polynomial */
6767
double calibration_linear(const void *params, size_t x);
6868
double calibration_poly(const void *params, size_t x);

src/fit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ size_t fit_data_ranges_calculate_number_of_channels(const struct fit_data *fit_d
783783
return sum;
784784
}
785785

786-
struct fit_stats fit_stats_init() {
786+
struct fit_stats fit_stats_init(void) {
787787
struct fit_stats s;
788788
s.n_evals = 0;
789789
s.n_evals_iter = 0;

src/fit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void fit_data_spectra_free(fit_data *fit);
145145
int fit_data_add_det(struct fit_data *fit, detector *det);
146146
fit_data_det *fit_data_fdd(const fit_data *fit, size_t i_det);
147147
size_t fit_data_ranges_calculate_number_of_channels(const struct fit_data *fit_data);
148-
struct fit_stats fit_stats_init();
148+
struct fit_stats fit_stats_init(void);
149149
int fit(fit_data *fit);
150150
void fit_covar_print(const gsl_matrix *covar, jabs_msg_level msg_level);
151151
int fit_parameters_set_from_vector(struct fit_data *fit, const gsl_vector *x); /* Updates values in fit params as they are varied by the fit algorithm. */

src/fit_params.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "jibal_generic.h"
1111

1212

13-
fit_params *fit_params_new() {
13+
fit_params *fit_params_new(void) {
1414
fit_params *p = malloc(sizeof(fit_params));
1515
p->n = 0;
1616
p->n_active = 0;

src/fit_params.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef struct fit_params {
2222
fit_variable *vars; /* Note that this is NOT an array of pointers. It has n elements. */
2323
} fit_params;
2424

25-
fit_params *fit_params_new();
25+
fit_params *fit_params_new(void);
2626
void fit_params_free(fit_params *p);
2727
int fit_params_add_parameter(fit_params *p, fit_variable_type type, double *value, const char *name, const char *unit, double unit_factor, size_t i_det); /* Pointer to parameter to be fitted (value) is accessed during fitting (read, write). No guarantees that it stays accessible after the fit is over and user decides to change something! */
2828
int fit_params_update(fit_params *p);

src/generic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ int jabs_unit_sanity_check(double value, int type) {
309309
}
310310

311311

312-
double jabs_clock() {
312+
double jabs_clock(void) {
313313
#ifdef _OPENMP
314314
return omp_get_wtime();
315315
#else

src/generic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ const char *jabs_file_extension_const(const char *filename);
4040
int jabs_unit_convert(const jibal_units *units, char type, const char *str, double *out); /* Wrapper for jibal_unit_convert with error reporting using jabs_message and sanity checker (jabs_unit_sanity_check()). Negative values are errors that should not be ignored. */
4141
int jabs_unit_sanity_check(double value, int type); /* returns 1 if no issue was found, returns 0 and prints a warning via jabs_message() if value is suspicious, and returns -1 for really crazy stuff */
4242
int jabs_str_to_size_t(const char *str, size_t *out);
43-
double jabs_clock();
43+
double jabs_clock(void);
4444
#endif //JABS_GENERIC_H

src/options.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626

2727
#define USAGE_STRING "Usage: jabs [OPTION [<argument>]] [OPTION2 ...] ... [<FILE> [<FILE2>] ...] | \n\nRun without arguments or \"-i\" to use JaBS interactively.\n\nExample: jabs example.jbs\n"
2828

29-
const char *jabs_version() {
29+
const char *jabs_version(void) {
3030
if(git_populated()) {
3131
return git_describe();
3232
}
3333
return jabs_version_simple();
3434
}
3535

36-
const char *jabs_version_simple() {
36+
const char *jabs_version_simple(void) {
3737
return jabs_VERSION;
3838
}
3939

40-
void usage() {
40+
void usage(void) {
4141
fprintf(stderr, USAGE_STRING);
4242
}
4343

@@ -115,7 +115,7 @@ void read_options(cmdline_options *cmd_opt, int *argc, char *const **argv) {
115115
*argv += optind;
116116
}
117117

118-
cmdline_options *cmdline_options_init() {
118+
cmdline_options *cmdline_options_init(void) {
119119
cmdline_options *cmd_opt = malloc(sizeof(cmdline_options));
120120
memset(cmd_opt, 0, sizeof(cmdline_options)); /* Everything not listed below are zero or NULL by default */
121121
cmd_opt->verbose = JABS_DEFAULT_VERBOSITY;

src/options.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ typedef struct {
2525
#include "simulation.h"
2626

2727
void read_options(cmdline_options *cmd_opt, int *argc, char *const **argv);
28-
cmdline_options *cmdline_options_init();
28+
cmdline_options *cmdline_options_init(void);
2929
void cmdline_options_free(cmdline_options *cmd_opt);
30-
const char *jabs_version(); /* Returns "git describe" given version, fallback to jabs_version_simple() */
31-
const char *jabs_version_simple(); /* Returns directly the CMake project version */
32-
void usage();
30+
const char *jabs_version(void); /* Returns "git describe" given version, fallback to jabs_version_simple() */
31+
const char *jabs_version_simple(void); /* Returns directly the CMake project version */
32+
void usage(void);
3333
void greeting(int interactive);
3434

3535
#endif // JABS_OPTIONS_H

src/plugin.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
#include "generic.h"
1919

2020
jabs_plugin *jabs_plugin_open(const char *filename) {
21-
jabs_plugin_type (*typef)();
22-
const char *(*namef)();
23-
const char *(*versionf)();
21+
jabs_plugin_type (*typef)(void);
22+
const char *(*namef)(void);
23+
const char *(*versionf)(void);
2424
if(!filename) {
2525
return NULL;
2626
}
@@ -34,9 +34,9 @@ jabs_plugin *jabs_plugin_open(const char *filename) {
3434
}
3535
plugin->handle = handle;
3636
plugin->filename = strdup(filename);
37-
namef = (const char *(*)()) dlsym(handle, "name");
38-
versionf = (const char *(*)()) dlsym(handle, "version");
39-
typef = (jabs_plugin_type (*)()) dlsym(handle, "type");
37+
namef = (const char *(*)(void)) dlsym(handle, "name");
38+
versionf = (const char *(*)(void)) dlsym(handle, "version");
39+
typef = (jabs_plugin_type (*)(void)) dlsym(handle, "type");
4040
if(!namef || !versionf || !typef) {
4141
DEBUGSTR("Plugin does not have name or version symbol.");
4242
jabs_plugin_close(plugin);

src/sample.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,7 @@ sample_model *sample_model_from_file(const jibal *jibal, const char *filename) {
620620
r->rough.model = ROUGHNESS_NONE;
621621
roughness_reset(&r->rough);
622622
sm->n_ranges++;
623-
#ifdef DEBUG
624-
fprintf(stderr, "Sample from file: NEW POINT, n = %zu, n_ranges = %zu, n_materials=%zu\n", n, sm->n_ranges, sm->n_materials);
625-
#endif
623+
DEBUGMSG("Sample from file: NEW POINT, n = %zu, n_ranges = %zu, n_materials=%zu", n, sm->n_ranges, sm->n_materials);
626624
i_material = 0;
627625
/* TODO: invalidate layer if not loaded properly */
628626
}
@@ -658,6 +656,9 @@ sample_model *sample_model_from_file(const jibal *jibal, const char *filename) {
658656
headers = 0;
659657
}
660658
free(line);
659+
fclose(in);
660+
jabs_message(MSG_VERBOSE, "Read %zu lines from \"%s\": got %zu ranges.\n", lineno, filename, sm->n_ranges);
661+
661662
for(size_t i_range = 0; i_range < sm->n_ranges; i_range++) { /* Set defaults (roughness model) for roughness. */
662663
sample_range *r = &sm->ranges[i_range];
663664
if(r->rough.x > ROUGH_TOLERANCE) {

src/script_command.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,13 @@ script_command_status script_fit(script_session *s, int argc, char *const *argv)
262262
}
263263

264264
script_command_status script_save_simulation(script_session *s, int argc, char *const *argv) {
265-
size_t i_det = 0;
266265
struct fit_data *fit = s->fit;
267266
const int argc_orig = argc;
268267
if(argc < 1) {
269268
jabs_message(MSG_ERROR, "Usage: save simulation <file>\n");
270269
return SCRIPT_COMMAND_FAILURE;
271270
}
272-
if(simulation2idf(s->fit, argv[0])) {
271+
if(simulation2idf(fit, argv[0])) {
273272
jabs_message(MSG_ERROR, "Could not save simulation to file %s.", argv[0]);
274273
return SCRIPT_COMMAND_FAILURE;
275274
}

src/simulation2idf.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ int simulation2idf(const struct fit_data *fit, const char *filename) {
7373
return EXIT_SUCCESS;
7474
}
7575

76-
xmlNodePtr simulation2idf_notes() {
76+
xmlNodePtr simulation2idf_notes(void) {
7777
xmlNodePtr notes = xmlNewNode(NULL, BAD_CAST "notes");
7878
xmlNodePtr note = xmlNewChild(notes, NULL, BAD_CAST "note", NULL);
7979

@@ -160,7 +160,7 @@ xmlNodePtr simulation2idf_spectra(const struct fit_data *fit) {
160160
xmlNodePtr spectrum = xmlNewNode(NULL, BAD_CAST "spectrum");
161161
xmlAddChild(spectrum, simulation2idf_beam(fit->sim));
162162
xmlAddChild(spectrum, simulation2idf_geometry(fit->sim, det));
163-
xmlAddChild(spectrum, simulation2idf_detection(fit->sim, det));
163+
xmlAddChild(spectrum, simulation2idf_detection(det));
164164
xmlAddChild(spectrum, simulation2idf_calibrations(fit->jibal->elements, fit->sim, det));
165165
xmlAddChild(spectrum, simulation2idf_reactions(fit->sim, det));
166166
if(i_det < fit->n_det_spectra) {
@@ -216,7 +216,7 @@ xmlNodePtr simulation2idf_geometry(const simulation *sim, const detector *det) {
216216
return geometry;
217217
}
218218

219-
xmlNodePtr simulation2idf_detection(const simulation *sim, const detector *det) {
219+
xmlNodePtr simulation2idf_detection(const detector *det) {
220220
xmlNodePtr detection = xmlNewNode(NULL, BAD_CAST "detection");
221221
xmlNodePtr detector = xmlNewChild(detection, NULL, BAD_CAST "detector", NULL);
222222
char *detectortype = NULL;
@@ -260,7 +260,6 @@ xmlNodePtr simulation2idf_detection(const simulation *sim, const detector *det)
260260
xmlNodePtr simulation2idf_calibrations(const jibal_element *elements, const simulation *sim, const detector *det) {
261261
xmlNodePtr calibrations = xmlNewNode(NULL, BAD_CAST "calibrations");
262262
xmlNodePtr detectorresolutions = xmlNewChild(calibrations, NULL, BAD_CAST "detectorresolutions", NULL);
263-
xmlNodePtr detectorresolution = simulation2idf_detectorresolution(det, det->calibration, NULL);
264263
xmlNodePtr energycalibrations = xmlNewChild(calibrations, NULL, BAD_CAST "energycalibrations", NULL);
265264
xmlAddChild(energycalibrations, simulation2idf_energycalibration(det, det->calibration, NULL));
266265
for(int Z = 0; Z <= det->cal_Z_max; Z++) {

src/simulation2idf.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
#include <libxml/parser.h>
2020

2121
int simulation2idf(const struct fit_data *fit, const char *filename);
22-
xmlNodePtr simulation2idf_notes();
22+
xmlNodePtr simulation2idf_notes(void);
2323
xmlNodePtr simulation2idf_attributes(const char *filename);
2424
xmlNodePtr simulation2idf_elementsandmolecules(const sample_model *sm);
2525
xmlNodePtr simulation2idf_structure(const sample_model *sm);
2626
xmlNodePtr simulation2idf_layers(const sample_model *sm);
2727
xmlNodePtr simulation2idf_spectra(const struct fit_data *fit);
2828
xmlNodePtr simulation2idf_beam(const simulation *sim);
2929
xmlNodePtr simulation2idf_geometry(const simulation *sim, const detector *det);
30-
xmlNodePtr simulation2idf_detection(const simulation *sim, const detector *det);
30+
xmlNodePtr simulation2idf_detection(const detector *det);
3131
xmlNodePtr simulation2idf_calibrations(const jibal_element *elements, const simulation *sim, const detector *det);
3232
xmlNodePtr simulation2idf_detectorresolution(const detector *det, const calibration *cal, const char *ion_name);
3333
xmlNodePtr simulation2idf_energycalibration(const detector *det, const calibration *cal, const char *ion_name);

0 commit comments

Comments
 (0)