Message ID | 20210615130921.55008-1-frankja@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] qobject: Fix maybe uninitialized in qdict_array_split | expand |
Le 15/06/2021 à 15:09, Janosch Frank a écrit : > Lets make the compiler happy. > Found on gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1) > > Signed-off-by: Janosch Frank <frankja@linux.ibm.com> > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > qobject/block-qdict.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c > index 1487cc5dd8..8d0f00bc3c 100644 > --- a/qobject/block-qdict.c > +++ b/qobject/block-qdict.c > @@ -224,7 +224,6 @@ void qdict_array_split(QDict *src, QList **dst) > for (i = 0; i < UINT_MAX; i++) { > QObject *subqobj; > bool is_subqdict; > - QDict *subqdict; > char indexstr[32], prefix[32]; > size_t snprintf_ret; > > @@ -249,14 +248,16 @@ void qdict_array_split(QDict *src, QList **dst) > } > > if (is_subqdict) { > + QDict *subqdict = NULL; > + I think the "= NULL" is not needed with the v2 as the setter (qdict_extract_subqdict()) and the user (qlist_append_obj()) are in the same block now. > qdict_extract_subqdict(src, &subqdict, prefix); > assert(qdict_size(subqdict) > 0); > + qlist_append_obj(*dst, QOBJECT(subqdict)); > } else { > qobject_ref(subqobj); > qdict_del(src, indexstr); > + qlist_append_obj(*dst, subqobj); > } > - > - qlist_append_obj(*dst, subqobj ?: QOBJECT(subqdict)); > } > } > > Thanks, Laurent
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c index 1487cc5dd8..8d0f00bc3c 100644 --- a/qobject/block-qdict.c +++ b/qobject/block-qdict.c @@ -224,7 +224,6 @@ void qdict_array_split(QDict *src, QList **dst) for (i = 0; i < UINT_MAX; i++) { QObject *subqobj; bool is_subqdict; - QDict *subqdict; char indexstr[32], prefix[32]; size_t snprintf_ret; @@ -249,14 +248,16 @@ void qdict_array_split(QDict *src, QList **dst) } if (is_subqdict) { + QDict *subqdict = NULL; + qdict_extract_subqdict(src, &subqdict, prefix); assert(qdict_size(subqdict) > 0); + qlist_append_obj(*dst, QOBJECT(subqdict)); } else { qobject_ref(subqobj); qdict_del(src, indexstr); + qlist_append_obj(*dst, subqobj); } - - qlist_append_obj(*dst, subqobj ?: QOBJECT(subqdict)); } }