Skip to contentSkip to conversation

smalloc: fix compiler warning

PATCH In review [email protected] 2 participants 3 messages Jul 31, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smalloc: fix compiler warning

From: Vincent Fu <[email protected]>

firstfree() triggers a warning from the Windows compiler used by AppVeyor because it doesn't return a value if the for loop iterates to completion. This patch resolves the compiler warning.

AppVeyor Windows build log: https://ci.appveyor.com/project/axboe/fio/builds/26381726

---
 smalloc.c | 3 +++
 1 file changed, 3 insertions(+)
smalloc.c +3 -0
index c97bcbaa..0d7054a4 100644
@@ -347,6 +347,9 @@ static unsigned int firstfree(struct pool *pool)
                         return i;
 
         assert(0);
+
+	/* we will never get here but this fixes a compiler warning */
+	return -1U;
 }
 
 static void *__smalloc_pool(struct pool *pool, size_t size)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 16 lines · On 7/31/19 2:57 PM, [email protected] wrote:

From: Vincent Fu <[email protected]>

firstfree() triggers a warning from the Windows compiler used by AppVeyor because it doesn't return a value if the for loop iterates to completion. This patch resolves the compiler warning.

AppVeyor Windows build log: https://ci.appveyor.com/project/axboe/fio/builds/26381726

---
  smalloc.c | 3 +++
  1 file changed, 3 insertions(+)
smalloc.c +0 -0
index c97bcbaa..0d7054a4 100644

smalloc.c static unsigned int firstfree(struct pool *pool) · line 353

Quoted 7 lines
smalloc.c +3 -0
@@ -347,6 +347,9 @@ static unsigned int firstfree(struct pool *pool)
                          return i;
 
          assert(0);
+
+	/* we will never get here but this fixes a compiler warning */
+	return -1U;
  }

Thanks, a bit ugly (for Windows), but no big deal.

Signature · 1 line
Jens Axboe
#2 lore raw
In reply to [email protected]
Quoted 7 lines · On 7/31/19 2:57 PM, [email protected] wrote:

From: Vincent Fu <[email protected]>

firstfree() triggers a warning from the Windows compiler used by AppVeyor because it doesn't return a value if the for loop iterates to completion. This patch resolves the compiler warning.

AppVeyor Windows build log: https://ci.appveyor.com/project/axboe/fio/builds/26381726

I did this on top, as it removes the need to have that weird assert() with a return. Also fixes the coding style (mix of tabs and spaces), and makes it easier to read imho. Please review!

http://git.kernel.dk/cgit/fio/commit/?id=21eabccd000aaa36ff8af2cd0db833e0871ed85b

Signature · 1 line
Jens Axboe