summaryrefslogtreecommitdiff
path: root/0432-glusterd-Fix-coverity-defects-put-coverity-annotatio.patch
blob: ef589dea3e02dfea0017afb67933181079269557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
From aa215163cb7d806dc98bef2386a4e282a5e54a31 Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Thu, 25 Apr 2019 12:00:52 +0530
Subject: [PATCH 432/449] glusterd: Fix coverity defects & put coverity
 annotations

Along with fixing few defect, put the required annotations for the defects which
are marked ignore/false positive/intentional as per the coverity defect sheet.
This should avoid the per component graph showing many defects as open in the
coverity glusterfs web page.

> upstream patch link: https://review.gluster.org/#/c/glusterfs/+/22619/
> Updates: bz#789278
> Change-Id: I19461dc3603a3bd8f88866a1ab3db43d783af8e4
> Signed-off-by: Atin Mukherjee <amukherj@redhat.com>

BUG: 1787310
Change-Id: I19461dc3603a3bd8f88866a1ab3db43d783af8e4
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/202631
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 xlators/mgmt/glusterd/src/glusterd-brick-ops.c     |  7 +++--
 xlators/mgmt/glusterd/src/glusterd-geo-rep.c       |  3 +-
 .../glusterd/src/glusterd-gfproxyd-svc-helper.c    |  2 +-
 xlators/mgmt/glusterd/src/glusterd-handler.c       |  8 ++++-
 xlators/mgmt/glusterd/src/glusterd-mountbroker.c   |  5 ++-
 xlators/mgmt/glusterd/src/glusterd-op-sm.c         |  8 +++++
 xlators/mgmt/glusterd/src/glusterd-peer-utils.c    |  2 ++
 xlators/mgmt/glusterd/src/glusterd-server-quorum.c |  1 +
 xlators/mgmt/glusterd/src/glusterd-store.c         |  4 ---
 xlators/mgmt/glusterd/src/glusterd-svc-helper.c    |  4 +--
 xlators/mgmt/glusterd/src/glusterd-syncop.c        |  1 +
 .../mgmt/glusterd/src/glusterd-tierd-svc-helper.c  |  4 +--
 xlators/mgmt/glusterd/src/glusterd-utils.c         |  9 ++++--
 xlators/mgmt/glusterd/src/glusterd-volgen.c        | 36 +++++++++++++---------
 14 files changed, 63 insertions(+), 31 deletions(-)

diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index d424f31..121346c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -2032,7 +2032,6 @@ glusterd_op_stage_remove_brick(dict_t *dict, char **op_errstr)
         case GF_OP_CMD_STATUS:
             ret = 0;
             goto out;
-
         case GF_OP_CMD_DETACH_START:
             if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
                 snprintf(msg, sizeof(msg),
@@ -2044,7 +2043,7 @@ glusterd_op_stage_remove_brick(dict_t *dict, char **op_errstr)
                        errstr);
                 goto out;
             }
-
+        /* Fall through */
         case GF_OP_CMD_START: {
             if ((volinfo->type == GF_CLUSTER_TYPE_REPLICATE) &&
                 dict_getn(dict, "replica-count", SLEN("replica-count"))) {
@@ -2259,7 +2258,8 @@ out:
         if (op_errstr)
             *op_errstr = errstr;
     }
-
+    if (!op_errstr && errstr)
+        GF_FREE(errstr);
     return ret;
 }
 
@@ -2687,6 +2687,7 @@ glusterd_op_remove_brick(dict_t *dict, char **op_errstr)
              * Update defrag_cmd as well or it will only be done
              * for nodes on which the brick to be removed exists.
              */
+            /* coverity[MIXED_ENUMS] */
             volinfo->rebal.defrag_cmd = cmd;
             volinfo->rebal.defrag_status = GF_DEFRAG_STATUS_NOT_STARTED;
             ret = dict_get_strn(dict, GF_REMOVE_BRICK_TID_KEY,
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 85c06c1..5a91df4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -4107,6 +4107,7 @@ gd_pause_or_resume_gsync(dict_t *dict, char *master, char *slave,
 
 out:
     sys_close(pfd);
+    /* coverity[INTEGER_OVERFLOW] */
     return ret;
 }
 
@@ -4183,7 +4184,7 @@ stop_gsync(char *master, char *slave, char **msg, char *conf_path,
 
 out:
     sys_close(pfd);
-
+    /* coverity[INTEGER_OVERFLOW] */
     return ret;
 }
 
diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c
index 67e3f41..e338bf4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c
@@ -111,7 +111,7 @@ glusterd_svc_get_gfproxyd_volfile(glusterd_volinfo_t *volinfo, char *svc_name,
         goto out;
     }
 
-    /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */
+    /* coverity[SECURE_TEMP] mkstemp uses 0600 as the mode and is safe */
     tmp_fd = mkstemp(*tmpvol);
     if (tmp_fd < 0) {
         gf_msg("glusterd", GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED,
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 2e73c98..1f31e72 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -930,6 +930,7 @@ __glusterd_handle_cluster_lock(rpcsvc_request_t *req)
 
     op_ctx = dict_new();
     if (!op_ctx) {
+        ret = -1;
         gf_msg(this->name, GF_LOG_ERROR, ENOMEM, GD_MSG_DICT_CREATE_FAIL,
                "Unable to set new dict");
         goto out;
@@ -956,6 +957,9 @@ out:
     glusterd_friend_sm();
     glusterd_op_sm();
 
+    if (ret)
+        GF_FREE(ctx);
+
     return ret;
 }
 
@@ -3470,6 +3474,7 @@ glusterd_rpc_create(struct rpc_clnt **rpc, dict_t *options,
     GF_ASSERT(this);
 
     GF_ASSERT(options);
+    GF_VALIDATE_OR_GOTO(this->name, rpc, out);
 
     if (force && rpc && *rpc) {
         (void)rpc_clnt_unref(*rpc);
@@ -3482,7 +3487,6 @@ glusterd_rpc_create(struct rpc_clnt **rpc, dict_t *options,
         goto out;
 
     ret = rpc_clnt_register_notify(new_rpc, notify_fn, notify_data);
-    *rpc = new_rpc;
     if (ret)
         goto out;
     ret = rpc_clnt_start(new_rpc);
@@ -3491,6 +3495,8 @@ out:
         if (new_rpc) {
             (void)rpc_clnt_unref(new_rpc);
         }
+    } else {
+        *rpc = new_rpc;
     }
 
     gf_msg_debug(this->name, 0, "returning %d", ret);
diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
index 332ddef..c017ccb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
@@ -334,7 +334,10 @@ make_ghadoop_mountspec(gf_mount_spec_t *mspec, const char *volname, char *user,
     if (ret == -1)
         return ret;
 
-    return parse_mount_pattern_desc(mspec, hadoop_mnt_desc);
+    ret = parse_mount_pattern_desc(mspec, hadoop_mnt_desc);
+    GF_FREE(hadoop_mnt_desc);
+
+    return ret;
 }
 
 static gf_boolean_t
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 6475611..46fc607 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2467,6 +2467,7 @@ glusterd_start_bricks(glusterd_volinfo_t *volinfo)
         if (!brickinfo->start_triggered) {
             pthread_mutex_lock(&brickinfo->restart_mutex);
             {
+                /* coverity[SLEEP] */
                 ret = glusterd_brick_start(volinfo, brickinfo, _gf_false,
                                            _gf_false);
             }
@@ -3466,6 +3467,7 @@ _add_task_to_dict(dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index)
 
     switch (op) {
         case GD_OP_REMOVE_TIER_BRICK:
+        /* Fall through */
         case GD_OP_REMOVE_BRICK:
             snprintf(key, sizeof(key), "task%d", index);
             ret = _add_remove_bricks_to_dict(dict, volinfo, key);
@@ -7550,6 +7552,7 @@ glusterd_op_ac_send_brick_op(glusterd_op_sm_event_t *event, void *ctx)
     glusterd_op_t op = GD_OP_NONE;
     glusterd_req_ctx_t *req_ctx = NULL;
     char *op_errstr = NULL;
+    gf_boolean_t free_req_ctx = _gf_false;
 
     this = THIS;
     priv = this->private;
@@ -7558,6 +7561,9 @@ glusterd_op_ac_send_brick_op(glusterd_op_sm_event_t *event, void *ctx)
         req_ctx = ctx;
     } else {
         req_ctx = GF_CALLOC(1, sizeof(*req_ctx), gf_gld_mt_op_allack_ctx_t);
+        if (!req_ctx)
+            goto out;
+        free_req_ctx = _gf_true;
         op = glusterd_op_get_op();
         req_ctx->op = op;
         gf_uuid_copy(req_ctx->uuid, MY_UUID);
@@ -7588,6 +7594,8 @@ glusterd_op_ac_send_brick_op(glusterd_op_sm_event_t *event, void *ctx)
     }
 
 out:
+    if (ret && req_ctx && free_req_ctx)
+        GF_FREE(req_ctx);
     gf_msg_debug(this->name, 0, "Returning with %d", ret);
 
     return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
index 8c1feeb..1a65359 100644
--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
@@ -82,6 +82,7 @@ glusterd_peerinfo_cleanup(glusterd_peerinfo_t *peerinfo)
     call_rcu(&peerinfo->rcu_head.head, glusterd_peerinfo_destroy);
 
     if (quorum_action)
+        /* coverity[SLEEP] */
         glusterd_do_quorum_action();
     return 0;
 }
@@ -358,6 +359,7 @@ glusterd_uuid_to_hostname(uuid_t uuid)
 
     if (!gf_uuid_compare(MY_UUID, uuid)) {
         hostname = gf_strdup("localhost");
+        return hostname;
     }
     RCU_READ_LOCK;
     if (!cds_list_empty(&priv->peers)) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c
index fd334e6..f378187 100644
--- a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c
+++ b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c
@@ -372,6 +372,7 @@ glusterd_do_volume_quorum_action(xlator_t *this, glusterd_volinfo_t *volinfo,
             if (!brickinfo->start_triggered) {
                 pthread_mutex_lock(&brickinfo->restart_mutex);
                 {
+                    /* coverity[SLEEP] */
                     ret = glusterd_brick_start(volinfo, brickinfo, _gf_false,
                                                _gf_false);
                 }
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index b3b5ee9..4fa8116 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -4764,10 +4764,6 @@ glusterd_store_retrieve_peers(xlator_t *this)
          */
         address = cds_list_entry(peerinfo->hostnames.next,
                                  glusterd_peer_hostname_t, hostname_list);
-        if (!address) {
-            ret = -1;
-            goto next;
-        }
         peerinfo->hostname = gf_strdup(address->hostname);
 
         ret = glusterd_friend_add_from_peerinfo(peerinfo, 1, NULL);
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
index ca19a75..1d1f42d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
@@ -179,7 +179,7 @@ glusterd_svc_check_volfile_identical(char *svc_name,
         goto out;
     }
 
-    /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */
+    /* coverity[SECURE_TEMP] mkstemp uses 0600 as the mode and is safe */
     tmp_fd = mkstemp(tmpvol);
     if (tmp_fd < 0) {
         gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED,
@@ -241,7 +241,7 @@ glusterd_svc_check_topology_identical(char *svc_name,
         goto out;
     }
 
-    /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */
+    /* coverity[SECURE_TEMP] mkstemp uses 0600 as the mode and is safe */
     tmpfd = mkstemp(tmpvol);
     if (tmpfd < 0) {
         gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED,
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index 618d8bc..9e47d14 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -1752,6 +1752,7 @@ gd_brick_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
                 if (dict_get(op_ctx, "client-count"))
                     break;
             }
+            /* coverity[MIXED_ENUMS] */
         } else if (cmd == GF_OP_CMD_DETACH_START) {
             op = GD_OP_REMOVE_BRICK;
             dict_del(req_dict, "rebalance-command");
diff --git a/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c
index 922eae7..59843a0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c
@@ -116,7 +116,7 @@ glusterd_svc_check_tier_volfile_identical(char *svc_name,
         goto out;
     }
 
-    /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */
+    /* coverity[SECURE_TEMP] mkstemp uses 0600 as the mode and is safe */
     tmp_fd = mkstemp(tmpvol);
     if (tmp_fd < 0) {
         gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED,
@@ -177,7 +177,7 @@ glusterd_svc_check_tier_topology_identical(char *svc_name,
         goto out;
     }
 
-    /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */
+    /* coverity[SECURE_TEMP] mkstemp uses 0600 as the mode and is safe */
     tmpfd = mkstemp(tmpvol);
     if (tmpfd < 0) {
         gf_msg(this->name, GF_LOG_WARNING, errno, GD_MSG_FILE_OP_FAILED,
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 14e23d1..8b0fc9a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -908,6 +908,7 @@ glusterd_create_sub_tier_volinfo(glusterd_volinfo_t *volinfo,
         (*dup_volinfo)->brick_count = tier_info->cold_brick_count;
     }
 out:
+    /* coverity[REVERSE_NULL] */
     if (ret && *dup_volinfo) {
         glusterd_volinfo_delete(*dup_volinfo);
         *dup_volinfo = NULL;
@@ -2738,6 +2739,7 @@ glusterd_readin_file(const char *filepath, int *line_count)
     /* Reduce allocation to minimal size.  */
     p = GF_REALLOC(lines, (counter + 1) * sizeof(char *));
     if (!p) {
+        /* coverity[TAINTED_SCALAR] */
         free_lines(lines, counter);
         lines = NULL;
         goto out;
@@ -6782,6 +6784,7 @@ glusterd_restart_bricks(void *opaque)
                 if (!brickinfo->start_triggered) {
                     pthread_mutex_lock(&brickinfo->restart_mutex);
                     {
+                        /* coverity[SLEEP] */
                         glusterd_brick_start(volinfo, brickinfo, _gf_false,
                                              _gf_false);
                     }
@@ -8886,7 +8889,7 @@ glusterd_nfs_statedump(char *options, int option_cnt, char **op_errstr)
     kill(pid, SIGUSR1);
 
     sleep(1);
-
+    /* coverity[TAINTED_STRING] */
     sys_unlink(dumpoptions_path);
     ret = 0;
 out:
@@ -9012,6 +9015,7 @@ glusterd_quotad_statedump(char *options, int option_cnt, char **op_errstr)
 
     sleep(1);
 
+    /* coverity[TAINTED_STRING] */
     sys_unlink(dumpoptions_path);
     ret = 0;
 out:
@@ -13423,7 +13427,7 @@ glusterd_get_global_options_for_all_vols(rpcsvc_request_t *req, dict_t *ctx,
         if (key_fixed)
             key = key_fixed;
     }
-
+    /* coverity[CONSTANT_EXPRESSION_RESULT] */
     ALL_VOLUME_OPTION_CHECK("all", _gf_true, key, ret, op_errstr, out);
 
     for (i = 0; valid_all_vol_opts[i].option; i++) {
@@ -14153,6 +14157,7 @@ glusterd_disallow_op_for_tier(glusterd_volinfo_t *volinfo, glusterd_op_t op,
             break;
         case GD_OP_REMOVE_BRICK:
             switch (cmd) {
+                /* coverity[MIXED_ENUMS] */
                 case GF_DEFRAG_CMD_DETACH_START:
                 case GF_OP_CMD_DETACH_COMMIT_FORCE:
                 case GF_OP_CMD_DETACH_COMMIT:
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 539e8a5..6852f8e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -322,7 +322,7 @@ volopt_trie_cbk(char *word, void *param)
 }
 
 static int
-process_nodevec(struct trienodevec *nodevec, char **hint)
+process_nodevec(struct trienodevec *nodevec, char **outputhint, char *inputhint)
 {
     int ret = 0;
     char *hint1 = NULL;
@@ -331,14 +331,14 @@ process_nodevec(struct trienodevec *nodevec, char **hint)
     trienode_t **nodes = nodevec->nodes;
 
     if (!nodes[0]) {
-        *hint = NULL;
+        *outputhint = NULL;
         return 0;
     }
 
 #if 0
         /* Limit as in git */
         if (trienode_get_dist (nodes[0]) >= 6) {
-                *hint = NULL;
+                *outputhint = NULL;
                 return 0;
         }
 #endif
@@ -347,23 +347,30 @@ process_nodevec(struct trienodevec *nodevec, char **hint)
         return -1;
 
     if (nodevec->cnt < 2 || !nodes[1]) {
-        *hint = hint1;
+        *outputhint = hint1;
         return 0;
     }
 
-    if (trienode_get_word(nodes[1], &hint2))
+    if (trienode_get_word(nodes[1], &hint2)) {
+        GF_FREE(hint1);
         return -1;
+    }
 
-    if (*hint)
-        hintinfx = *hint;
-    ret = gf_asprintf(hint, "%s or %s%s", hint1, hintinfx, hint2);
+    if (inputhint)
+        hintinfx = inputhint;
+    ret = gf_asprintf(outputhint, "%s or %s%s", hint1, hintinfx, hint2);
     if (ret > 0)
         ret = 0;
+    if (hint1)
+        GF_FREE(hint1);
+    if (hint2)
+        GF_FREE(hint2);
     return ret;
 }
 
 static int
-volopt_trie_section(int lvl, char **patt, char *word, char **hint, int hints)
+volopt_trie_section(int lvl, char **patt, char *word, char **outputhint,
+                    char *inputhint, int hints)
 {
     trienode_t *nodes[] = {NULL, NULL};
     struct trienodevec nodevec = {nodes, 2};
@@ -384,7 +391,7 @@ volopt_trie_section(int lvl, char **patt, char *word, char **hint, int hints)
     nodevec.cnt = hints;
     ret = trie_measure_vec(trie, word, &nodevec);
     if (!ret && nodevec.nodes[0])
-        ret = process_nodevec(&nodevec, hint);
+        ret = process_nodevec(&nodevec, outputhint, inputhint);
 
     trie_destroy(trie);
 
@@ -396,6 +403,7 @@ volopt_trie(char *key, char **hint)
 {
     char *patt[] = {NULL};
     char *fullhint = NULL;
+    char *inputhint = NULL;
     char *dot = NULL;
     char *dom = NULL;
     int len = 0;
@@ -405,7 +413,7 @@ volopt_trie(char *key, char **hint)
 
     dot = strchr(key, '.');
     if (!dot)
-        return volopt_trie_section(1, patt, key, hint, 2);
+        return volopt_trie_section(1, patt, key, hint, inputhint, 2);
 
     len = dot - key;
     dom = gf_strdup(key);
@@ -413,7 +421,7 @@ volopt_trie(char *key, char **hint)
         return -1;
     dom[len] = '\0';
 
-    ret = volopt_trie_section(0, NULL, dom, patt, 1);
+    ret = volopt_trie_section(0, NULL, dom, patt, inputhint, 1);
     GF_FREE(dom);
     if (ret) {
         patt[0] = NULL;
@@ -422,8 +430,8 @@ volopt_trie(char *key, char **hint)
     if (!patt[0])
         goto out;
 
-    *hint = "...";
-    ret = volopt_trie_section(1, patt, dot + 1, hint, 2);
+    inputhint = "...";
+    ret = volopt_trie_section(1, patt, dot + 1, hint, inputhint, 2);
     if (ret)
         goto out;
     if (*hint) {
-- 
1.8.3.1