summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-05-07 21:23:11 -0400
committermidipix <writeonce@midipix.org>2019-05-07 21:26:22 -0400
commitd7016c533d6091d6d4db30845f747b2d1c2610f0 (patch)
treec0adbcbf893d8d526e175b8a6e1e4c51d3350ef5
parenta4a68a0965094e460bdadfb216fa500ff16a78a3 (diff)
downloadperk-d7016c533d.tar.bz2
perk-d7016c533d.tar.xz
Do not refer to on-the-fly compound literals out of scope.
-rw-r--r--src/driver/pe_driver_ctx.c22
1 files 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);