From: Ian Abbott Date: Mon, 10 Dec 2007 13:20:19 +0000 (+0000) Subject: Avoid mixing declarations and code. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0b21f807831a9f15a99688aa003e9b2e09cdd729;p=comedilib.git Avoid mixing declarations and code. --- diff --git a/demo/choose_clock.c b/demo/choose_clock.c index 58ed44f..808fd78 100644 --- a/demo/choose_clock.c +++ b/demo/choose_clock.c @@ -36,6 +36,8 @@ int main(int argc, char *argv[]) int retval; lsampl_t clock_selection; struct parsed_options options; + comedi_insn insn; + lsampl_t data[3]; init_parsed_options(&options); options.freq = 0.; @@ -59,8 +61,6 @@ int main(int argc, char *argv[]) { printf("Clock period unspecified.\n"); } - comedi_insn insn; - lsampl_t data[3]; memset(&insn, 0, sizeof(comedi_insn)); insn.insn = INSN_CONFIG; insn.subdev = options.subdevice; diff --git a/demo/choose_filter.c b/demo/choose_filter.c index 787d689..781d1bb 100644 --- a/demo/choose_filter.c +++ b/demo/choose_filter.c @@ -36,6 +36,8 @@ int main(int argc, char *argv[]) int retval; lsampl_t filter_selection; struct parsed_options options; + comedi_insn insn; + lsampl_t data[2]; init_parsed_options(&options); parse_options(&options, argc, argv); @@ -47,8 +49,6 @@ int main(int argc, char *argv[]) } filter_selection = options.value; printf("Selecting filter %d on subdevice %d channel %d.\n", filter_selection, options.subdevice, options.channel); - comedi_insn insn; - lsampl_t data[2]; memset(&insn, 0, sizeof(comedi_insn)); insn.insn = INSN_CONFIG; insn.subdev = options.subdevice; diff --git a/demo/choose_routing.c b/demo/choose_routing.c index 1aa6b10..845c7a8 100644 --- a/demo/choose_routing.c +++ b/demo/choose_routing.c @@ -36,6 +36,8 @@ int main(int argc, char *argv[]) int retval; lsampl_t routing; struct parsed_options options; + comedi_insn insn; + lsampl_t data[2]; init_parsed_options(&options); options.freq = 0.; @@ -52,8 +54,6 @@ int main(int argc, char *argv[]) period_ns = 0; routing = options.value; printf("Selecting routing %d for channel %d on subdevice %d.\n", routing, options.channel, options.subdevice); - comedi_insn insn; - lsampl_t data[2]; memset(&insn, 0, sizeof(comedi_insn)); insn.insn = INSN_CONFIG; insn.subdev = options.subdevice; diff --git a/demo/gpct_buffered_counting.c b/demo/gpct_buffered_counting.c index 7ce69bf..c608777 100644 --- a/demo/gpct_buffered_counting.c +++ b/demo/gpct_buffered_counting.c @@ -37,6 +37,7 @@ int check_subdevice(comedi_t *device, int *subdevice, const char *device_filepath) { + int subdevice_type; int read_subdevice = comedi_get_read_subdevice(device); if(read_subdevice < 0) { @@ -50,7 +51,7 @@ int check_subdevice(comedi_t *device, int *subdevice, const char *device_filepat *subdevice, device_filepath, read_subdevice); return -1; } - int subdevice_type = comedi_get_subdevice_type(device, *subdevice); + subdevice_type = comedi_get_subdevice_type(device, *subdevice); if(subdevice_type < 0) { comedi_perror("comedi_get_subdevice_type()"); diff --git a/lib/calib.c b/lib/calib.c index b3115e4..0038c82 100644 --- a/lib/calib.c +++ b/lib/calib.c @@ -253,11 +253,13 @@ int _comedi_get_hardcal_converter( comedi_polynomial_t* polynomial) { comedi_range *range_ptr = comedi_get_range(dev, subdevice, channel, range); + lsampl_t maxdata; + if(range_ptr == NULL) { return -1; } - lsampl_t maxdata = comedi_get_maxdata(dev, subdevice, channel); + maxdata = comedi_get_maxdata(dev, subdevice, channel); if(maxdata == 0) { return -1; diff --git a/lib/calib_yacc.y b/lib/calib_yacc.y index ede8e99..f8725c7 100644 --- a/lib/calib_yacc.y +++ b/lib/calib_yacc.y @@ -279,8 +279,9 @@ extern void _comedi_cleanup_calibration( comedi_calibration_t *file_contents ) static comedi_polynomial_t* alloc_inverse_linear_polynomial(const comedi_polynomial_t *polynomial) { + comedi_polynomial_t *inverse; if(polynomial->order != 1) return NULL; - comedi_polynomial_t *inverse = malloc(sizeof(comedi_polynomial_t)); + inverse = malloc(sizeof(comedi_polynomial_t)); memset(inverse, 0, sizeof(comedi_polynomial_t)); inverse->order = 1; inverse->expansion_origin = polynomial->coefficients[0];