Skip to content

Commit af0c5f4

Browse files
committed
shell: use idf58() convenience function
Problem: A couple uses of flux_job_id_encode(3) in the job shell could be replaced with the simpler idf58() convenience function. Replace flux_job_id_encode(3) with idf58() where it makes sense in the job shell.
1 parent 161fa8a commit af0c5f4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/shell/task.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <flux/core.h>
4343
#include <flux/shell.h>
4444

45+
#include "src/common/libjob/idf58.h"
4546
#include "src/common/libczmqcontainers/czmq_containers.h"
4647

4748
#include "internal.h"
@@ -98,7 +99,6 @@ struct shell_task *shell_task_create (struct shell_info *info,
9899
const char *key;
99100
json_t *entry;
100101
size_t i;
101-
char buf[64];
102102

103103
if (!(task = shell_task_new ()))
104104
return NULL;
@@ -130,10 +130,11 @@ struct shell_task *shell_task_create (struct shell_info *info,
130130
info->shell_size) < 0)
131131
goto error;
132132

133-
/* Attempt to encode jobid as F58 by default */
134-
if (flux_job_id_encode (info->jobid, "f58", buf, sizeof (buf)) < 0)
135-
snprintf (buf, sizeof (buf), "%ju", (uintmax_t)info->jobid);
136-
if (flux_cmd_setenvf (task->cmd, 1, "FLUX_JOB_ID", "%s", buf) < 0)
133+
if (flux_cmd_setenvf (task->cmd,
134+
1,
135+
"FLUX_JOB_ID",
136+
"%s",
137+
idf58 (info->jobid)) < 0)
137138
goto error;
138139

139140
/* Always unset FLUX_PROXY_REMOTE since this never makes sense

src/shell/tmpdir.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#endif
1616

1717
#include "src/common/libutil/cleanup.h"
18+
#include "src/common/libjob/idf58.h"
1819

1920
#include "builtins.h"
2021
#include "internal.h"
@@ -39,13 +40,16 @@ static int make_job_path (flux_shell_t *shell,
3940
{
4041
size_t n;
4142

42-
n = snprintf (buf, size, "%s/jobtmp-%d-", parent, shell->info->shell_rank);
43+
n = snprintf (buf,
44+
size,
45+
"%s/jobtmp-%d-%s",
46+
parent,
47+
shell->info->shell_rank,
48+
idf58 (shell->jobid));
4349
if (n >= size) {
4450
errno = EOVERFLOW;
4551
return -1;
4652
}
47-
if (flux_job_id_encode (shell->jobid, "f58", buf + n, size - n) < 0)
48-
return -1;
4953
return 0;
5054
}
5155

0 commit comments

Comments
 (0)