From 0c1cee625818275dd1b3f6718bd246d2e30dabd1 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Tue, 10 Jul 2012 10:19:16 -0400 Subject: calls to dict_allocate_and_serialize() are not 64-bit clean All calls to dict_allocate_and_serialize() pass the address of a 32-bit type, but must cast it to the 64-bit pointer type (size_t *). This happens to work on LE machines, but even if it's apparently benign, it's still a bug. On BE machines it is not benign. GF_PROTOCOL_DICT_SERIALIZE() hacks around it by creating a size_t temp var, but that's, well, a hack, IMO when you consider that all the callers are actually passing &; the param should just be a u_int * and eliminate the buggy casts and the temp var in the macro. Nobody apparently uses the Fedora/EPEL PPC RPMs, but they might. People are trying to build gluster.org bits on SPARC and tripping over this. Change-Id: I92ea139f9e3e91ddbbb32a51b96fa582a9515626 Signed-off-by: Kaleb S. KEITHLEY BUG: 838928 Reviewed-on: http://review.gluster.com/3643 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/dict.c | 2 +- libglusterfs/src/dict.h | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index 9b0d7ff18..ee265c9db 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -2450,7 +2450,7 @@ out: */ int32_t -dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length) +dict_allocate_and_serialize (dict_t *this, char **buf, u_int *length) { int ret = -EINVAL; ssize_t len = 0; diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h index 4e7cf2406..3f0fc436c 100644 --- a/libglusterfs/src/dict.h +++ b/libglusterfs/src/dict.h @@ -29,13 +29,11 @@ typedef struct _data_pair data_pair_t; #define GF_PROTOCOL_DICT_SERIALIZE(this,from_dict,to,len,ope,labl) do { \ int ret = 0; \ - size_t dictlen = 0; \ \ if (!from_dict) \ break; \ \ - ret = dict_allocate_and_serialize (from_dict, to, \ - &dictlen); \ + ret = dict_allocate_and_serialize (from_dict, to, &len);\ if (ret < 0) { \ gf_log (this->name, GF_LOG_WARNING, \ "failed to get serialized dict (%s)", \ @@ -43,7 +41,6 @@ typedef struct _data_pair data_pair_t; ope = EINVAL; \ goto labl; \ } \ - len = dictlen; \ } while (0) @@ -114,7 +111,7 @@ int32_t dict_serialized_length (dict_t *dict); int32_t dict_serialize (dict_t *dict, char *buf); int32_t dict_unserialize (char *buf, int32_t size, dict_t **fill); -int32_t dict_allocate_and_serialize (dict_t *this, char **buf, size_t *length); +int32_t dict_allocate_and_serialize (dict_t *this, char **buf, u_int *length); void dict_destroy (dict_t *dict); void dict_unref (dict_t *dict); -- cgit