From: Ben Pfaff Date: Fri, 9 Feb 2007 05:19:08 +0000 (+0000) Subject: Fix use of size_t in printf formats. Patch #5727. X-Git-Tag: v0.6.0~556 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59d14e5581317e3d1e37c8b92b535ba197984776;p=pspp-builds.git Fix use of size_t in printf formats. Patch #5727. --- diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index 2fa02ded..9441bcf8 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -430,9 +430,9 @@ read_version_data (struct pfm_reader *r, struct pfm_read_info *info) /* Validate file. */ if (strlen (date) != 8) - error (r, _("Bad date string length %d."), strlen (date)); + error (r, _("Bad date string length %d."), (int) strlen (date)); if (strlen (time) != 6) - error (r, _("Bad time string length %d."), strlen (time)); + error (r, _("Bad time string length %d."), (int) strlen (time)); /* Save file info. */ if (info != NULL) diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 9a4b33a9..47e5ddb4 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -472,8 +472,8 @@ read_variable_record (struct sfm_reader *r, struct dictionary *dict, len = read_int32 (r); if (len >= sizeof label) - sys_error (r, _("Variable %s has label of invalid length %d."), - name, len); + sys_error (r, _("Variable %s has label of invalid length %u."), + name, (unsigned int) len); read_string (r, label, len + 1); var_set_label (var, label); @@ -736,9 +736,9 @@ read_machine_int32_info (struct sfm_reader *r, size_t size, size_t count) int expected_integer_format; if (size != 4 || count != 8) - sys_error (r, _("Bad size (%d) or count (%d) field on record type 7, " + sys_error (r, _("Bad size (%u) or count (%u) field on record type 7, " "subtype 3."), - size, count); + (unsigned int) size, (unsigned int) count); /* Check floating point format. */ if (r->float_format == FLOAT_IEEE_DOUBLE_BE @@ -781,8 +781,8 @@ read_machine_flt64_info (struct sfm_reader *r, size_t size, size_t count) double lowest = read_flt64 (r); if (size != 8 || count != 3) - sys_error (r, _("Bad size (%d) or count (%d) on extension 4."), - size, count); + sys_error (r, _("Bad size (%u) or count (%u) on extension 4."), + (unsigned int) size, (unsigned int) count); if (sysmis != SYSMIS) sys_warn (r, _("File specifies unexpected value %g as SYSMIS."), sysmis); @@ -803,8 +803,8 @@ read_display_parameters (struct sfm_reader *r, size_t size, size_t count, int i; if (count % 3 || n_vars != dict_get_var_cnt (dict)) - sys_error (r, _("Bad size (%d) or count (%d) on extension 11."), - size, count); + sys_error (r, _("Bad size (%u) or count (%u) on extension 11."), + (unsigned int) size, (unsigned int) count); for (i = 0; i < n_vars; ++i) { @@ -1003,8 +1003,8 @@ read_value_labels (struct sfm_reader *r, var_cnt = read_int32 (r); if (var_cnt < 1 || var_cnt > dict_get_var_cnt (dict)) sys_error (r, _("Number of variables associated with a value label (%d) " - "is not between 1 and the number of variables (%d)."), - var_cnt, dict_get_var_cnt (dict)); + "is not between 1 and the number of variables (%u)."), + var_cnt, (unsigned int) dict_get_var_cnt (dict)); /* Read the list of variables. */ var = pool_nalloc (subpool, var_cnt, sizeof *var); diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index 6ace9128..01fdbd1e 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -98,12 +98,12 @@ cmd_file_handle (struct lexer *lexer, struct dataset *ds) if (cmd.n_lrecl[0] == NOT_LONG) msg (SE, _("Fixed-length records were specified on /RECFORM, but " "record length was not specified on /LRECL. " - "Assuming %d-character records."), - properties.record_width); + "Assuming %u-character records."), + (unsigned int) properties.record_width); else if (cmd.n_lrecl[0] < 1) msg (SE, _("Record length (%ld) must be at least one byte. " - "Assuming %d-character records."), - cmd.n_lrecl[0], properties.record_width); + "Assuming %u-character records."), + cmd.n_lrecl[0], (unsigned int) properties.record_width); else properties.record_width = cmd.n_lrecl[0]; break; diff --git a/src/language/data-io/placement-parser.c b/src/language/data-io/placement-parser.c index 2d3af8fe..81e3fee8 100644 --- a/src/language/data-io/placement-parser.c +++ b/src/language/data-io/placement-parser.c @@ -117,8 +117,8 @@ fixed_parse_columns (struct lexer *lexer, struct pool *pool, size_t var_cnt, boo if ((lc - fc + 1) % var_cnt) { msg (SE, _("The %d columns %d-%d " - "can't be evenly divided into %d fields."), - lc - fc + 1, fc, lc, var_cnt); + "can't be evenly divided into %u fields."), + lc - fc + 1, fc, lc, (unsigned int) var_cnt); return false; } diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c index 91a3f27b..bdc9ff61 100644 --- a/src/language/data-io/print.c +++ b/src/language/data-io/print.c @@ -257,9 +257,9 @@ parse_specs (struct lexer *lexer, struct pool *tmp_pool, struct print_trns *trns } if (trns->record_cnt != 0 && trns->record_cnt != record) - msg (SW, _("Output calls for %d records but %d specified on RECORDS " + msg (SW, _("Output calls for %d records but %u specified on RECORDS " "subcommand."), - record, trns->record_cnt); + record, (unsigned int) trns->record_cnt); trns->record_cnt = record; return true; diff --git a/src/language/dictionary/modify-variables.c b/src/language/dictionary/modify-variables.c index c74cd529..c1f71538 100644 --- a/src/language/dictionary/modify-variables.c +++ b/src/language/dictionary/modify-variables.c @@ -210,7 +210,8 @@ cmd_modify_vars (struct lexer *lexer, struct dataset *ds) { msg (SE, _("Differing number of variables in old name list " "(%d) and in new name list (%d)."), - vm.rename_cnt - prev_nv_2, prev_nv_1 - prev_nv_2); + (int) (vm.rename_cnt - prev_nv_2), + (int) (prev_nv_1 - prev_nv_2)); for (i = 0; i < prev_nv_1; i++) free (vm.new_names[i]); free (vm.new_names); diff --git a/src/language/dictionary/rename-variables.c b/src/language/dictionary/rename-variables.c index 1d7d7f52..06f3527c 100644 --- a/src/language/dictionary/rename-variables.c +++ b/src/language/dictionary/rename-variables.c @@ -75,9 +75,9 @@ cmd_rename_variables (struct lexer *lexer, struct dataset *ds) size_t i; msg (SE, _("Differing number of variables in old name list " - "(%u) and in new name list (%u)."), - (unsigned) rename_cnt - prev_nv_2, - (unsigned) prev_nv_1 - prev_nv_2); + "(%d) and in new name list (%d)."), + (int) (rename_cnt - prev_nv_2), + (int) (prev_nv_1 - prev_nv_2)); for (i = 0; i < prev_nv_1; i++) free (rename_new_names[i]); free (rename_new_names); diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 4f9c51ff..ebe98015 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -132,8 +132,8 @@ cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED) : info.float_format == FLOAT_Z_LONG ? _("IBM 390 Hex Long.") : _("Unknown.")); tab_text (t, 0, 5, TAB_LEFT, _("Variables:")); - tab_text (t, 1, 5, TAB_LEFT | TAT_PRINTF, "%d", - dict_get_var_cnt (d)); + tab_text (t, 1, 5, TAB_LEFT | TAT_PRINTF, "%u", + (unsigned int) dict_get_var_cnt (d)); tab_text (t, 0, 6, TAB_LEFT, _("Cases:")); tab_text (t, 1, 6, TAB_LEFT | TAT_PRINTF, info.case_cnt == -1 ? _("Unknown") : "%d", info.case_cnt); diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index ebb8a9ed..68dd1c86 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -1047,7 +1047,7 @@ convert_numeric_string_to_char_string (struct lexer *lexer, if (ds_length (&lexer->tokstr) % chars_per_byte) msg (SE, _("String of %s digits has %d characters, which is not a " "multiple of %d."), - base_name, ds_length (&lexer->tokstr), chars_per_byte); + base_name, (int) ds_length (&lexer->tokstr), chars_per_byte); p = ds_cstr (&lexer->tokstr); for (i = 0; i < byte_cnt; i++) @@ -1184,7 +1184,7 @@ finish: if (ds_length (&lexer->tokstr) > 255) { msg (SE, _("String exceeds 255 characters in length (%d characters)."), - ds_length (&lexer->tokstr)); + (int) ds_length (&lexer->tokstr)); ds_truncate (&lexer->tokstr, 255); } diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index d1cfb7dd..57dce080 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -520,8 +520,8 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, s } else { - msg (SE, _("Missing argument %d to %s."), i + 1, - function->name); + msg (SE, _("Missing argument %d to %s."), + (int) i + 1, function->name); goto error; } diff --git a/src/language/stats/descriptives.c b/src/language/stats/descriptives.c index 1f7fed89..edfcca08 100644 --- a/src/language/stats/descriptives.c +++ b/src/language/stats/descriptives.c @@ -175,7 +175,7 @@ static bool try_name (const struct dictionary *dict, struct dsc_proc *dsc, const char *name); static bool generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc, char *z_name, - const char *name, size_t *z_cnt); + const char *name, int *z_cnt); static void dump_z_table (struct dsc_proc *); static void setup_z_trns (struct dsc_proc *, struct dataset *); @@ -196,7 +196,7 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) struct variable **vars = NULL; size_t var_cnt = 0; int save_z_scores = 0; - size_t z_cnt = 0; + int z_cnt = 0; size_t i; bool ok; @@ -370,7 +370,7 @@ cmd_descriptives (struct lexer *lexer, struct dataset *ds) { if (save_z_scores) { - size_t gen_cnt = 0; + int gen_cnt = 0; for (i = 0; i < dsc->var_cnt; i++) if (dsc->vars[i].z_name[0] == 0) @@ -491,7 +491,7 @@ try_name (const struct dictionary *dict, struct dsc_proc *dsc, copies the new name into Z_NAME. On failure, returns false. */ static bool generate_z_varname (const struct dictionary *dict, struct dsc_proc *dsc, char *z_name, - const char *var_name, size_t *z_cnt) + const char *var_name, int *z_cnt) { char name[LONG_NAME_LEN + 1]; diff --git a/src/language/stats/npar.q b/src/language/stats/npar.q index 2f99b614..581452a2 100644 --- a/src/language/stats/npar.q +++ b/src/language/stats/npar.q @@ -421,7 +421,7 @@ parse_two_sample_related_test (struct lexer *lexer, if ( n_vlist1 != n_vlist2) msg (SE, _("PAIRED was specified but the number of variables " "preceding WITH (%d) did not match the number " - "following (%d)."), n_vlist1, n_vlist2); + "following (%d)."), (int) n_vlist1, (int) n_vlist2); test_parameters->n_pairs = n_vlist1 ; } diff --git a/src/language/stats/oneway.q b/src/language/stats/oneway.q index c63dc3a7..7664f607 100644 --- a/src/language/stats/oneway.q +++ b/src/language/stats/oneway.q @@ -175,7 +175,8 @@ output_oneway(void) sum += subc_list_double_at(&cmd.dl_contrast[i],j); if ( sum != 0.0 ) - msg(SW,_("Coefficients for contrast %d do not total zero"),i + 1); + msg(SW,_("Coefficients for contrast %d do not total zero"), + (int) i + 1); } if ( stat_tables & STAT_DESC ) diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index 287847a8..4679d075 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -765,8 +765,8 @@ reg_print_categorical_encoding (FILE * fp, pspp_linreg_cache * c) for (i = 0; i < n_vars; i++) { - size_t n_categories = cat_get_n_categories (varlist[i]); - size_t j; + int n_categories = cat_get_n_categories (varlist[i]); + int j; fprintf (fp, "%s.name = \"%s\";\n\t", var_get_name (varlist[i]), diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q index 450a9aba..088bc2b1 100644 --- a/src/language/stats/t-test.q +++ b/src/language/stats/t-test.q @@ -485,7 +485,7 @@ tts_custom_pairs (struct lexer *lexer, struct dataset *ds, struct cmd_t_test *cm msg (SE, _("PAIRED was specified but the number of variables " "preceding WITH (%d) did not match the number " "following (%d)."), - n_before_WITH, n_after_WITH ); + (int) n_before_WITH, (int) n_after_WITH ); return 0; } n_pairs_local = n_before_WITH; diff --git a/src/language/tests/moments-test.c b/src/language/tests/moments-test.c index e973b45e..e62a3432 100644 --- a/src/language/tests/moments-test.c +++ b/src/language/tests/moments-test.c @@ -125,7 +125,7 @@ cmd_debug_moments (struct lexer *lexer, struct dataset *ds UNUSED) fprintf (stderr, "W=%.3f", weight); for (i = 0; i < 4; i++) { - fprintf (stderr, " M%d=", i + 1); + fprintf (stderr, " M%d=", (int) i + 1); if (M[i] == SYSMIS) fprintf (stderr, "sysmis"); else if (fabs (M[i]) <= 0.0005) diff --git a/src/math/sort.c b/src/math/sort.c index d3e4446d..46da0ec0 100644 --- a/src/math/sort.c +++ b/src/math/sort.c @@ -467,8 +467,9 @@ allocate_cases (struct initial_run_state *irs) { msg (SE, _("Out of memory. Could not allocate room for minimum of %d " "cases of %d bytes each. (PSPP workspace is currently " - "restricted to a maximum of %d KB.)"), - min_buffers, approx_case_cost, get_workspace() / 1024); + "restricted to a maximum of %lu KB.)"), + min_buffers, approx_case_cost, + (unsigned long int) (get_workspace() / 1024)); return 0; } return 1; diff --git a/src/output/html.c b/src/output/html.c index 043965ee..caaaacb7 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -375,7 +375,7 @@ html_initialise_chart (struct outp_driver *this, struct chart *ch) number_pos = strchr (x->chart_file_name, '#') - x->chart_file_name; ch->file_name = xasprintf ("%.*s%d%s", number_pos, x->chart_file_name, - x->chart_cnt, + (int) x->chart_cnt, x->chart_file_name + number_pos + 1); fp = fopen (ch->file_name, "wb"); if (fp == NULL)