i965: Silence warning.
authorMatt Turner <mattst88@gmail.com>
Fri, 13 Nov 2015 20:13:14 +0000 (12:13 -0800)
committerMatt Turner <mattst88@gmail.com>
Fri, 13 Nov 2015 20:13:14 +0000 (12:13 -0800)
intel_asm_annotation.c: In function ‘annotation_insert_error’:
intel_asm_annotation.c:214:18:
warning: ‘ann’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
       ann->error = ralloc_strdup(annotation->mem_ctx, error);
                         ^

I initially tried changing the type of ann_count to unsigned (is
currently int), since that in addition to the check that it's non-zero
at the beginning of the function seems sufficient to prove that it must
be greater than zero. Unfortunately that wasn't sufficient.

src/mesa/drivers/dri/i965/intel_asm_annotation.c

index 52878fde43eb5f14518ea4a39206e22766594627..bb7786ba7484b731cbfbaf8c9e84627b5ecff9fb 100644 (file)
@@ -185,6 +185,8 @@ annotation_insert_error(struct annotation_info *annotation, unsigned offset,
    if (!annotation_array_ensure_space(annotation))
       return;
 
+   assume(annotation->ann_count > 0);
+
    for (int i = 0; i < annotation->ann_count; i++) {
       struct annotation *cur = &annotation->ann[i];
       struct annotation *next = &annotation->ann[i + 1];
@@ -206,8 +208,6 @@ annotation_insert_error(struct annotation_info *annotation, unsigned offset,
       break;
    }
 
-   assume(ann != NULL);
-
    if (ann->error)
       ralloc_strcat(&ann->error, error);
    else