[tarantool-patches] Re: [PATCH v1] build: LTO release build fails

Alexander Turenko alexander.turenko at tarantool.org
Fri Sep 20 17:14:13 MSK 2019


LGTM.

To be honest, I don't like such changes, because 0 is not some special
value here: it is part of range of valid variable values. But it worth
to keep -Wmaybe-uninitialized warning, because sometimes it gives useful
input; see:

https://github.com/tarantool/tarantool/commit/e55396c87e2560540bc46f3b8935bee8d8b057d7
(re struct http_praser)
https://github.com/tarantool/tarantool/commit/c308f35d8807dd08d8c0b6e281fa2391d3c31161
(re xrow_decode_*())

CCed Vlad to give glance on this too.

WBR, Alexander Turenko.

On Thu, Sep 19, 2019 at 11:17:57AM +0300, Alexander V. Tikhonov wrote:
> LTO build failed because of warnings on the uninitialized
> variables treated as errors:
> 
> /mnt/src/box/tuple_update.c: In function ‘do_op_splice’:
> /mnt/src/box/tuple_update.c:764:15: error: ‘str_len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    arg->offset = str_len;
>                ^
> /mnt/src/box/tuple_update.c:755:10: note: ‘str_len’ was declared here
>   int32_t str_len;
>           ^
> /mnt/src/box/tuple_update.c: In function ‘do_op_bit’:
> /mnt/src/box/tuple_update.c:725:12: error: ‘val’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    arg->val &= val;
>             ^
> /mnt/src/box/tuple_update.c:720:11: note: ‘val’ was declared here
>   uint64_t val;
>            ^
> /mnt/src/box/tuple_update.c: In function ‘update_read_ops’:
> /mnt/src/box/tuple_update.c:1068:4: error: ‘field_no’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>     diag_set(ClientError, ER_NO_SUCH_FIELD_NO, field_no);
>     ^
> /mnt/src/box/tuple_update.c:1057:10: note: ‘field_no’ was declared here
>   int32_t field_no;
>           ^
> lto1: all warnings being treated as errors
> 
> Fixed by setting variables to 0 value on initializations.

I would add that all those warnings are false positives, because
mp_read_*() functions are always set output parameters when zero is
returned.

> 
> Closed #4512
> ---
> 
> Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-4512-lto-build-full-ci
> Issue: https://github.com/tarantool/tarantool/issues/4512
> 
>  src/box/tuple_update.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/box/tuple_update.c b/src/box/tuple_update.c
> index 42f5190af..66f48f317 100644
> --- a/src/box/tuple_update.c
> +++ b/src/box/tuple_update.c
> @@ -717,7 +717,7 @@ do_op_bit(struct tuple_update *update, struct update_op *op)
>  	if (field->op != NULL)
>  		return update_err_double(op);
>  	const char *old = field->old;
> -	uint64_t val;
> +	uint64_t val = 0;
>  	if (mp_read_uint(op, &old, &val) != 0)
>  		return -1;
>  	switch (op->opcode) {
> @@ -752,7 +752,7 @@ do_op_splice(struct tuple_update *update, struct update_op *op)
>  	struct op_splice_arg *arg = &op->arg.splice;
>  
>  	const char *in = field->old;
> -	int32_t str_len;
> +	int32_t str_len = 0;
>  	if (mp_read_str(op, &in, (uint32_t *) &str_len, &in) != 0)
>  		return -1;
>  
> @@ -1054,7 +1054,7 @@ update_op_decode(struct update_op *op, int index_base,
>  		diag_set(ClientError, ER_UNKNOWN_UPDATE_OP);
>  		return -1;
>  	}
> -	int32_t field_no;
> +	int32_t field_no = 0;
>  	switch(mp_typeof(**expr)) {
>  	case MP_INT:
>  	case MP_UINT: {
> -- 
> 2.17.1
> 




More information about the Tarantool-patches mailing list