From 8d8328919cbd3b27f9494324f257bcf682e6baca Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 27 May 2022 20:30:30 +0300 Subject: [PATCH 42/42] Protocol: Make plocation.number size_t Extracted and modified from a patch by christian montanari See osdn #44693 Signed-off-by: Marko Lindqvist --- common/networking/dataio_raw.c | 2 +- common/networking/dataio_raw.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/networking/dataio_raw.c b/common/networking/dataio_raw.c index 7304776234..ac43f716c0 100644 --- a/common/networking/dataio_raw.c +++ b/common/networking/dataio_raw.c @@ -1138,7 +1138,7 @@ const char *plocation_name(const struct plocation *loc) case PADR_FIELD: return loc->name; case PADR_ELEMENT: - fc_snprintf(locname, sizeof(locname), "%d", loc->number); + fc_snprintf(locname, sizeof(locname), SIZE_T_PRINTF, loc->number); return locname; } diff --git a/common/networking/dataio_raw.h b/common/networking/dataio_raw.h index 3eadecd6d2..b403cf6e71 100644 --- a/common/networking/dataio_raw.h +++ b/common/networking/dataio_raw.h @@ -35,7 +35,7 @@ struct data_in { struct raw_data_out { void *dest; size_t dest_size, used, current; - bool too_short; /* set to 1 if try to read past end */ + bool too_short; /* set to 1 if try to read past end */ }; /* Used for dio__type() methods. @@ -65,8 +65,9 @@ struct plocation { enum plocation_kind kind; union { + // PTZ190716 int is too small for indexing /* Used if this is an array element */ - int number; + size_t number; /* Used if this is a field. */ char *name; @@ -91,7 +92,7 @@ typedef char *(*DIO_PUT_CONV_FUN) (const char *src, size_t *length); void dio_set_put_conv_callback(DIO_PUT_CONV_FUN fun); typedef bool(*DIO_GET_CONV_FUN) (char *dst, size_t ndst, - const char *src, size_t nsrc); + const char *src, size_t nsrc); void dio_set_get_conv_callback(DIO_GET_CONV_FUN fun); bool dataio_get_conv_callback(char *dst, size_t ndst, const char *src, @@ -99,7 +100,7 @@ bool dataio_get_conv_callback(char *dst, size_t ndst, const char *src, /* General functions */ void dio_output_init(struct raw_data_out *dout, void *destination, - size_t dest_size); + size_t dest_size); void dio_output_rewind(struct raw_data_out *dout); size_t dio_output_used(struct raw_data_out *dout); -- 2.35.1