Skip to content

Commit 06ebd99

Browse files
committed
shell: tmpdir: simplify mkjobtmp_tmpdir()
Problem: The mkjobtmp_tmpdir() function fetches TMPDIR from the job environment, but the calling function has already done so. Add a tmpdir parameter to mkjobtmp_tmpdir() so it does not have to be looked up again.
1 parent 8beeaad commit 06ebd99

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/shell/tmpdir.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ static int mkjobtmp_rundir (flux_shell_t *shell, char *buf, size_t size)
6161
return 0;
6262
}
6363

64-
static int mkjobtmp_tmpdir (flux_shell_t *shell, char *buf, size_t size)
64+
static int mkjobtmp_tmpdir (flux_shell_t *shell,
65+
const char *tmpdir,
66+
char *buf,
67+
size_t size)
6568
{
66-
const char *tmpdir = flux_shell_getenv (shell, "TMPDIR");
67-
6869
if (make_job_path (shell, tmpdir ? tmpdir : "/tmp", buf, size) < 0
6970
|| mkdir_exist_ok (buf, false) < 0)
7071
return -1;
@@ -94,7 +95,7 @@ static int tmpdir_init (flux_plugin_t *p,
9495
* Fall back to ${TMPDIR:-/tmp} if that fails (e.g. guest user).
9596
*/
9697
if (mkjobtmp_rundir (shell, jobtmp, sizeof (jobtmp)) < 0
97-
&& mkjobtmp_tmpdir (shell, jobtmp, sizeof (jobtmp)) < 0)
98+
&& mkjobtmp_tmpdir (shell, tmpdir, jobtmp, sizeof (jobtmp)) < 0)
9899
shell_die_errno (1, "error creating FLUX_JOB_TMPDIR");
99100
cleanup_push_string (cleanup_directory_recursive, jobtmp);
100101

0 commit comments

Comments
 (0)