Skip to content

Commit bb79a83

Browse files
committed
kvs: use optional key when unpacking json
Problem: In lookup_common() multiple calls to flux_request_unpack() are made for optional json keys. This is likely legacy from before jansson's "?" optional flag was available. Remove the excess calls to flux_request_unpack(), using the "?" optional flag as needed.
1 parent 3d8207b commit bb79a83

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/modules/kvs/kvs.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,25 +1317,17 @@ static lookup_t *lookup_common (flux_t *h, flux_msg_handler_t *mh,
13171317
struct flux_msg_cred cred;
13181318
int root_seq = -1;
13191319

1320-
if (flux_request_unpack (msg, NULL, "{ s:s s:i }",
1320+
/* namespace, rootdir, and rootseq optional */
1321+
if (flux_request_unpack (msg, NULL, "{ s:s s:i s?s s?o s?i}",
13211322
"key", &key,
1322-
"flags", &flags) < 0) {
1323+
"flags", &flags,
1324+
"namespace", &ns,
1325+
"rootdir", &root_dirent,
1326+
"rootseq", &root_seq) < 0) {
13231327
flux_log_error (h, "%s: flux_request_unpack", __FUNCTION__);
13241328
goto done;
13251329
}
13261330

1327-
/* namespace is optional */
1328-
(void)flux_request_unpack (msg, NULL, "{ s:s }",
1329-
"namespace", &ns);
1330-
1331-
/* rootdir is optional */
1332-
(void)flux_request_unpack (msg, NULL, "{ s:o }",
1333-
"rootdir", &root_dirent);
1334-
1335-
/* rootseq is optional */
1336-
(void)flux_request_unpack (msg, NULL, "{ s:i }",
1337-
"rootseq", &root_seq);
1338-
13391331
/* either namespace or rootdir must be specified */
13401332
if (!ns && !root_dirent) {
13411333
errno = EPROTO;

0 commit comments

Comments
 (0)