[PATCH] ctdb-daemon: Fix maybe-uninitialized error with picky developer

Jeremy Allison jra at samba.org
Fri Mar 1 04:42:31 UTC 2019


On Fri, Mar 01, 2019 at 02:21:55PM +1100, Amitay Isaacs via samba-technical wrote:
> Hi,
> 
> Fix the new error added by commit 55acae774a9994715043dfe6e7668c19f514c545.
> 
> Please review and push.

Oh sorry about missing that. Absolutely right, it's now
calling

+               goto failed;

before initializing the mem_ctx.

RB+ and pushed (although a cleaner fix is to move the new
strtoul_err() code after the:

mem_ctx = talloc_new(NULL);

call (IMHO of course :-).

Thanks,

Jeremy.

> From f6588973618e9f70b19115a173b2615d6445e766 Mon Sep 17 00:00:00 2001
> From: Amitay Isaacs <amitay at gmail.com>
> Date: Fri, 1 Mar 2019 14:18:31 +1100
> Subject: [PATCH] ctdb-daemon: Fix maybe-uninitialized error with picky
>  developer
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> 263/386] Compiling ctdb/server/ctdb_recovery_helper.c
> In file included from ../../server/ctdb_recovery_helper.c:24:0:
> ../../server/ctdb_recovery_helper.c: In function ‘main’:
> ../../../lib/talloc/talloc.h:911:34: error: ‘mem_ctx’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>  #define TALLOC_FREE(ctx) do { if (ctx != NULL) { talloc_free(ctx); ctx=NULL; } } while(0)
> 
> Signed-off-by: Amitay Isaacs <amitay at gmail.com>
> ---
>  ctdb/server/ctdb_recovery_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ctdb/server/ctdb_recovery_helper.c b/ctdb/server/ctdb_recovery_helper.c
> index 57e12b47037..eed71da5df8 100644
> --- a/ctdb/server/ctdb_recovery_helper.c
> +++ b/ctdb/server/ctdb_recovery_helper.c
> @@ -2737,7 +2737,7 @@ int main(int argc, char *argv[])
>  {
>  	int write_fd;
>  	const char *sockpath;
> -	TALLOC_CTX *mem_ctx;
> +	TALLOC_CTX *mem_ctx = NULL;
>  	struct tevent_context *ev;
>  	struct ctdb_client_context *client;
>  	int ret = 0;
> -- 
> 2.20.1
> 




More information about the samba-technical mailing list