[libvirt PATCH 4/4] tools: be more paranoid about possibly NULL description

Daniel P. Berrangé posted 4 patches 5 years, 6 months ago
[libvirt PATCH 4/4] tools: be more paranoid about possibly NULL description
Posted by Daniel P. Berrangé 5 years, 6 months ago
GCC 10 complains about "desc" possibly being a NULL dereference. Even
though it is a false positive, we can easily avoid it.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tools/vsh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 527c135424..b65e99cbd2 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -689,7 +689,7 @@ vshCmddefHelp(vshControl *ctl, const vshCmdDef *def)
     fputc('\n', stdout);
 
     desc = vshCmddefGetInfo(def, "desc");
-    if (*desc) {
+    if (desc && *desc) {
         /* Print the description only if it's not empty.  */
         fputs(_("\n  DESCRIPTION\n"), stdout);
         fprintf(stdout, "    %s\n", _(desc));
-- 
2.24.1

Re: [libvirt PATCH 4/4] tools: be more paranoid about possibly NULL description
Posted by Michal Privoznik 5 years, 6 months ago
On 7/22/20 7:21 PM, Daniel P. Berrangé wrote:
> GCC 10 complains about "desc" possibly being a NULL dereference. Even
> though it is a false positive, we can easily avoid it.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tools/vsh.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal

Re: [libvirt PATCH 4/4] tools: be more paranoid about possibly NULL description
Posted by Laine Stump 5 years, 6 months ago
On 7/22/20 1:21 PM, Daniel P. Berrangé wrote:
> GCC 10 complains about "desc" possibly being a NULL dereference. Even
> though it is a false positive, we can easily avoid it.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


Reviewed-by: Laine Stump <laine@redhat.com>



So those were the only complaints of gcc 10? We got off easy :-)


> ---
>   tools/vsh.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/vsh.c b/tools/vsh.c
> index 527c135424..b65e99cbd2 100644
> --- a/tools/vsh.c
> +++ b/tools/vsh.c
> @@ -689,7 +689,7 @@ vshCmddefHelp(vshControl *ctl, const vshCmdDef *def)
>       fputc('\n', stdout);
>   
>       desc = vshCmddefGetInfo(def, "desc");
> -    if (*desc) {
> +    if (desc && *desc) {
>           /* Print the description only if it's not empty.  */
>           fputs(_("\n  DESCRIPTION\n"), stdout);
>           fprintf(stdout, "    %s\n", _(desc));