tgsi/dump: signal nospace when the last print exceeded the size
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 28 Apr 2016 20:51:25 +0000 (15:51 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 29 Apr 2016 16:39:28 +0000 (11:39 -0500)
Previously, there was a bug where nospace wasn't signalled if it just so
happened that the very last print exceeded the available space.

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/auxiliary/tgsi/tgsi_dump.c

index 9482644..473fed1 100644 (file)
@@ -753,7 +753,7 @@ str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
 {
    struct str_dump_ctx *sctx = (struct str_dump_ctx *)ctx;
    
-   if(sctx->left > 1) {
+   if (!sctx->nospace) {
       int written;
       va_list ap;
       va_start(ap, format);
@@ -764,12 +764,14 @@ str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
        * vsnprintf:
        */
       if (written > 0) {
-         written = MIN2(sctx->left, written);
+         if (written >= sctx->left) {
+            sctx->nospace = true;
+            written = sctx->left;
+         }
          sctx->ptr += written;
          sctx->left -= written;
       }
-   } else
-      sctx->nospace = true;
+   }
 }
 
 bool