From d7016c533d6091d6d4db30845f747b2d1c2610f0 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 7 May 2019 21:23:11 -0400 Subject: Do not refer to on-the-fly compound literals out of scope. --- src/driver/pe_driver_ctx.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/driver/pe_driver_ctx.c b/src/driver/pe_driver_ctx.c index 13eef59..1509ec3 100644 --- a/src/driver/pe_driver_ctx.c +++ b/src/driver/pe_driver_ctx.c @@ -24,6 +24,16 @@ static const struct pe_source_version pe_src_version = { PERK_GIT_VERSION }; +/* default fd context */ +static const struct pe_fd_ctx pe_default_fdctx = { + .fdin = STDIN_FILENO, + .fdout = STDOUT_FILENO, + .fderr = STDERR_FILENO, + .fdcwd = AT_FDCWD, + .fddst = AT_FDCWD, + .fdlog = (-1), +}; + struct pe_driver_ctx_alloc { struct argv_meta * meta; struct pe_driver_ctx_impl ctx; @@ -127,16 +137,8 @@ int pe_get_driver_ctx( (void)envp; - if (!fdctx) { - fdctx = &(const struct pe_fd_ctx) { - .fdin = STDIN_FILENO, - .fdout = STDOUT_FILENO, - .fderr = STDERR_FILENO, - .fdlog = (-1), - .fdcwd = AT_FDCWD, - .fddst = AT_FDCWD, - }; - } + if (!fdctx) + fdctx = &pe_default_fdctx; argv_optv_init(pe_default_options,optv); -- cgit v1.2.3