client: Make skipping option appending in handle_job_opt() more selective
authorBart Van Assche <bvanassche@acm.org>
Fri, 7 Feb 2020 14:54:29 +0000 (06:54 -0800)
committerBart Van Assche <bvanassche@acm.org>
Sun, 24 May 2020 22:12:30 +0000 (15:12 -0700)
Instead of not appending an option to the option list if JSON output is
disabled, only skip appending an option to the JSON option list. See also
commit b127b679769c ("client: fix segfault for !json output").

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
client.c

index 134497cb99c1e5b2dce58a6415106146a7e98661..84fc1f531009e39bae4ac5852b6a2eb32e247b9b 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1141,14 +1141,14 @@ static void handle_job_opt(struct fio_client *client, struct fio_net_cmd *cmd)
 {
        struct cmd_job_option *pdu = (struct cmd_job_option *) cmd->payload;
 
-       if (!job_opt_object)
-               return;
-
        pdu->global = le16_to_cpu(pdu->global);
        pdu->truncated = le16_to_cpu(pdu->truncated);
        pdu->groupid = le32_to_cpu(pdu->groupid);
 
        if (pdu->global) {
+               if (!job_opt_object)
+                       return;
+
                json_object_add_value_string(job_opt_object,
                                             (const char *)pdu->name,
                                             (const char *)pdu->value);