From 6d45988d64cee1c83900da412be55b82b6d40059 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 7 May 2019 21:16:47 -0400 Subject: Do not refer to on-the-fly compound literals out of scope. --- src/driver/mdso_driver_ctx.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/driver/mdso_driver_ctx.c b/src/driver/mdso_driver_ctx.c index 59450ac..32683b6 100644 --- a/src/driver/mdso_driver_ctx.c +++ b/src/driver/mdso_driver_ctx.c @@ -33,6 +33,16 @@ static const struct mdso_source_version mdso_src_version = { MDSO_GIT_VERSION }; +/* default fd context */ +static const struct mdso_fd_ctx mdso_default_fdctx = { + .fdin = STDIN_FILENO, + .fdout = STDOUT_FILENO, + .fderr = STDERR_FILENO, + .fdcwd = AT_FDCWD, + .fddst = AT_FDCWD, + .fdlog = (-1), +}; + struct mdso_driver_ctx_alloc { struct argv_meta * meta; struct mdso_driver_ctx_impl ctx; @@ -188,16 +198,8 @@ int mdso_get_driver_ctx( (void)envp; - if (!fdctx) { - fdctx = &(const struct mdso_fd_ctx) { - .fdin = STDIN_FILENO, - .fdout = STDOUT_FILENO, - .fderr = STDERR_FILENO, - .fdlog = (-1), - .fdcwd = AT_FDCWD, - .fddst = AT_FDCWD, - }; - } + if (!fdctx) + fdctx = &mdso_default_fdctx; argv_optv_init(mdso_default_options,optv); -- cgit v1.2.3