All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9]
@ 2017-04-14 21:06 kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 1/9] Fix num2str() output when modulo != -1U kusumi.tomohiro
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

"Fix num2str() output when modulo != -1U" is a resend of below,
which I believe has been neither acked nor nacked.
http://www.spinics.net/lists/fio/msg05719.html

The patch is the same, but added a link to below comment to the commit message.
http://www.spinics.net/lists/fio/msg05720.html

All the rest are new ones.

Tomohiro Kusumi (9):
  Fix num2str() output when modulo != -1U
  Drop the only local variable declaration within a for-loop (C99)
  Make lib/strntol.c a stand-alone library
  Make lib/pattern.c a stand-alone library
  Make lib/rand.c a stand-alone library
  Make lib/zipf.c a stand-alone library
  Make lib/mountcheck.c a stand-alone library
  Make oslib/strlcat.c a stand-alone library
  Make oslib/linux-dev-lookup.c a stand-alone library

 lib/mountcheck.c         |  2 +-
 lib/num2str.c            | 34 +++++++++++++++++++++-------------
 lib/pattern.c            |  9 ++++++++-
 lib/rand.c               |  2 +-
 lib/strntol.c            |  2 +-
 lib/zipf.c               |  1 -
 oslib/linux-dev-lookup.c |  3 +--
 oslib/strlcat.c          |  2 +-
 parse.c                  |  3 ++-
 9 files changed, 36 insertions(+), 22 deletions(-)

-- 
2.9.3



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/9] Fix num2str() output when modulo != -1U
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 2/9] Drop the only local variable declaration within a for-loop (C99) kusumi.tomohiro
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

I'm not sure what 05463816 actually fixed (as it only says "fix"),
but this isn't properly working at least for some input numbers unless
".%s" part of sprintf() is meant to be something other than decimal
part of the input number.

This commit might be breaking something that 05463816 had fixed,
which then needs to be rejected, but it at least prints decimal number
as expected. For example, when 12345 is 12.0556640625 KiB, and 23456
is 22.90625 KiB,

 # python -c "print(12345.0 / 1024)"
 12.0556640625
 # python -c "print(23456.0 / 1024)"
 22.90625

running this code as well as fio result in

 # cat ./test1.c
 #include <stdio.h>
 #include "lib/num2str.h"
 int main(void) {
         printf("%s-%s\n",
                 num2str(12345, 4, 1, 1, N2S_BYTE),
                 num2str(23456, 4, 1, 1, N2S_BYTE));
         return 0;
 }
 # gcc -Wall -g -DCONFIG_STATIC_ASSERT ./test1.c ./lib/num2str.c

below with the current implementation

 # ./a.out
 12.6KiB-22.1KiB
 # ./fio --name=xxxxx --ioengine=sync --rw=read --size=1m --unlink=1 --bsrange=12345:23456 | grep "rw=read"
 xxxxx: (g=0): rw=read, bs=(R) 12.6KiB-22.1KiB, (W) 12.6KiB-22.1KiB, (T) 12.6KiB-22.1KiB, ioengine=sync, iodepth=1

whereas below with this commit.

 # ./a.out
 12.1KiB-22.9KiB
 # ./fio --name=xxxxx --ioengine=sync --rw=read --size=1m --unlink=1 --bsrange=12345:23456 | grep "rw=read"
 xxxxx: (g=0): rw=read, bs=(R) 12.1KiB-22.9KiB, (W) 12.1KiB-22.9KiB, (T) 12.1KiB-22.9KiB, ioengine=sync, iodepth=1

-- Also see below
http://www.spinics.net/lists/fio/msg05720.html
 > > +	sprintf(fmt, "%%.%df", (int)(maxlen - strlen(tmp) - 1));
 > > +	sprintf(tmp, fmt, (double)modulo / (double)thousand[!!pow2]);
 >
 > I suspect one of the goals of that function was to restrict itself
 > to integer math and avoid invoking the floating point unit (which
 > might not even exist on some CPUs).

-- These are some more verification with various parameters
 # cat ./testx.c
 #include <stdio.h>
 #include "lib/num2str.h"
 static void f(uint64_t n, int maxlen, int base, int pow2, int units) {
 	printf("%10jd %s\n", n, num2str(n, maxlen, base, pow2, units));
 }
 int main(void) {
 	/* 1 */
 	f(1, 1, 1, 1, N2S_BYTE);
 	f(1, 1, 1, 0, N2S_BYTE);
 	printf("====================\n");
 	/* 10 */
 	f(10, 2, 1, 1, N2S_BYTE);
 	f(10, 2, 1, 0, N2S_BYTE);
 	printf("====================\n");
 	/* 1000 */
 	f(1000, 5, 1, 1, N2S_BYTE);
 	f(1000, 5, 1, 0, N2S_BYTE);
 	f(1000, 4, 1, 1, N2S_BYTE);
 	f(1000, 4, 1, 0, N2S_BYTE);
 	f(1000, 3, 1, 1, N2S_BYTE);
 	f(1000, 3, 1, 0, N2S_BYTE);
 	f(1000, 2, 1, 1, N2S_BYTE);
 	f(1000, 2, 1, 0, N2S_BYTE);
 	f(1000, 1, 1, 1, N2S_BYTE);
 	f(1000, 1, 1, 0, N2S_BYTE);
 	printf("====================\n");
 	/* 1024 */
 	f(1024, 5, 1, 1, N2S_BYTE);
 	f(1024, 5, 1, 0, N2S_BYTE);
 	f(1024, 4, 1, 1, N2S_BYTE);
 	f(1024, 4, 1, 0, N2S_BYTE);
 	f(1024, 3, 1, 1, N2S_BYTE);
 	f(1024, 3, 1, 0, N2S_BYTE);
 	f(1024, 2, 1, 1, N2S_BYTE);
 	f(1024, 2, 1, 0, N2S_BYTE);
 	f(1024, 1, 1, 1, N2S_BYTE);
 	f(1024, 1, 1, 0, N2S_BYTE);
 	printf("====================\n");
 	/* 12345 */
 	f(12345, 6, 1, 1, N2S_BYTE);
 	f(12345, 6, 1, 0, N2S_BYTE);
 	f(12345, 5, 1, 1, N2S_BYTE);
 	f(12345, 5, 1, 0, N2S_BYTE);
 	f(12345, 4, 1, 1, N2S_BYTE);
 	f(12345, 4, 1, 0, N2S_BYTE);
 	f(12345, 3, 1, 1, N2S_BYTE);
 	f(12345, 3, 1, 0, N2S_BYTE);
 	f(12345, 2, 1, 1, N2S_BYTE);
 	f(12345, 2, 1, 0, N2S_BYTE);
 	f(12345, 1, 1, 1, N2S_BYTE);
 	f(12345, 1, 1, 0, N2S_BYTE);
 	printf("====================\n");
 	/* 1234567 */
 	f(1234567, 8, 1, 1, N2S_BYTE);
 	f(1234567, 8, 1, 0, N2S_BYTE);
 	f(1234567, 7, 1, 1, N2S_BYTE);
 	f(1234567, 7, 1, 0, N2S_BYTE);
 	f(1234567, 6, 1, 1, N2S_BYTE);
 	f(1234567, 6, 1, 0, N2S_BYTE);
 	f(1234567, 5, 1, 1, N2S_BYTE);
 	f(1234567, 5, 1, 0, N2S_BYTE);
 	f(1234567, 4, 1, 1, N2S_BYTE);
 	f(1234567, 4, 1, 0, N2S_BYTE);
 	f(1234567, 3, 1, 1, N2S_BYTE);
 	f(1234567, 3, 1, 0, N2S_BYTE);
 	f(1234567, 2, 1, 1, N2S_BYTE);
 	f(1234567, 2, 1, 0, N2S_BYTE);
 	f(1234567, 1, 1, 1, N2S_BYTE);
 	f(1234567, 1, 1, 0, N2S_BYTE);
 	printf("====================\n");
 	/* 1234567 with base 1024 */
 	f(1234567, 8, 1024, 1, N2S_BYTE);
 	f(1234567, 8, 1024, 0, N2S_BYTE);
 	f(1234567, 7, 1024, 1, N2S_BYTE);
 	f(1234567, 7, 1024, 0, N2S_BYTE);
 	f(1234567, 6, 1024, 1, N2S_BYTE);
 	f(1234567, 6, 1024, 0, N2S_BYTE);
 	f(1234567, 5, 1024, 1, N2S_BYTE);
 	f(1234567, 5, 1024, 0, N2S_BYTE);
 	f(1234567, 4, 1024, 1, N2S_BYTE);
 	f(1234567, 4, 1024, 0, N2S_BYTE);
 	f(1234567, 3, 1024, 1, N2S_BYTE);
 	f(1234567, 3, 1024, 0, N2S_BYTE);
 	f(1234567, 2, 1024, 1, N2S_BYTE);
 	f(1234567, 2, 1024, 0, N2S_BYTE);
 	f(1234567, 1, 1024, 1, N2S_BYTE);
 	f(1234567, 1, 1024, 0, N2S_BYTE);
 	printf("====================\n");
 	/* 1234567 with base 1024 with N2S_BIT */
 	f(1234567, 9, 1024, 1, N2S_BIT);
 	f(1234567, 9, 1024, 0, N2S_BIT);
 	f(1234567, 8, 1024, 1, N2S_BIT);
 	f(1234567, 8, 1024, 0, N2S_BIT);
 	f(1234567, 7, 1024, 1, N2S_BIT);
 	f(1234567, 7, 1024, 0, N2S_BIT);
 	f(1234567, 6, 1024, 1, N2S_BIT);
 	f(1234567, 6, 1024, 0, N2S_BIT);
 	f(1234567, 5, 1024, 1, N2S_BIT);
 	f(1234567, 5, 1024, 0, N2S_BIT);
 	f(1234567, 4, 1024, 1, N2S_BIT);
 	f(1234567, 4, 1024, 0, N2S_BIT);
 	f(1234567, 3, 1024, 1, N2S_BIT);
 	f(1234567, 3, 1024, 0, N2S_BIT);
 	f(1234567, 2, 1024, 1, N2S_BIT);
 	f(1234567, 2, 1024, 0, N2S_BIT);
 	f(1234567, 1, 1024, 1, N2S_BIT);
 	f(1234567, 1, 1024, 0, N2S_BIT);
 	printf("====================\n");
 	return 0;
 }
 # gcc -Wall -g -DCONFIG_STATIC_ASSERT ./testx.c ./lib/num2str.c
 # ./a.out
          1 1B
          1 1B
 ====================
         10 10B
         10 10B
 ====================
       1000 1000B
       1000 1000B
       1000 1000B
       1000 1000B
       1000 0.0KiB
       1000 1.0kB
       1000 1KiB
       1000 1kB
       1000 1KiB
       1000 1kB
 ====================
       1024 1024B
       1024 1024B
       1024 1024B
       1024 1024B
       1024 1.0KiB
       1024 1.0kB
       1024 1KiB
       1024 1kB
       1024 1KiB
       1024 1kB
 ====================
      12345 12345B
      12345 12345B
      12345 12345B
      12345 12345B
      12345 12.1KiB
      12345 12.3kB
      12345 12KiB
      12345 12kB
      12345 12KiB
      12345 12kB
      12345 0MiB
      12345 0MB
 ====================
    1234567 1234567B
    1234567 1234567B
    1234567 1234567B
    1234567 1234567B
    1234567 1205.6KiB
    1234567 1234.6kB
    1234567 1206KiB
    1234567 1235kB
    1234567 1206KiB
    1234567 1235kB
    1234567 1.2MiB
    1234567 1.2MB
    1234567 1MiB
    1234567 1MB
    1234567 1MiB
    1234567 1MB
 ====================
    1234567 1234567KiB
    1234567 1234567kB
    1234567 1234567KiB
    1234567 1234567kB
    1234567 1205.6MiB
    1234567 1234.6MB
    1234567 1206MiB
    1234567 1235MB
    1234567 1206MiB
    1234567 1235MB
    1234567 1.2GiB
    1234567 1.2GB
    1234567 1GiB
    1234567 1GB
    1234567 1GiB
    1234567 1GB
 ====================
    1234567 9876536Kibit
    1234567 9876536kbit
    1234567 9876536Kibit
    1234567 9876536kbit
    1234567 9876536Kibit
    1234567 9876536kbit
    1234567 9645.1Mibit
    1234567 9876.5Mbit
    1234567 9645Mibit
    1234567 9877Mbit
    1234567 9645Mibit
    1234567 9877Mbit
    1234567 9.4Gibit
    1234567 9.9Gbit
    1234567 9Gibit
    1234567 10Gbit
    1234567 9Gibit
    1234567 10Gbit
 ====================

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 lib/num2str.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/lib/num2str.c b/lib/num2str.c
index 448d3ff..8d08841 100644
--- a/lib/num2str.c
+++ b/lib/num2str.c
@@ -10,7 +10,7 @@
 /**
  * num2str() - Cheesy number->string conversion, complete with carry rounding error.
  * @num: quantity (e.g., number of blocks, bytes or bits)
- * @maxlen: max number of digits in the output string (not counting prefix and units)
+ * @maxlen: max number of digits in the output string (not counting prefix and units, but counting .)
  * @base: multiplier for num (e.g., if num represents Ki, use 1024)
  * @pow2: select unit prefix - 0=power-of-10 decimal SI, nonzero=power-of-2 binary IEC
  * @units: select units - N2S_* macros defined in num2str.h
@@ -23,9 +23,9 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)
 	const char **unitprefix;
 	const char *unitstr[] = { "", "/s", "B", "bit", "B/s", "bit/s" };
 	const unsigned int thousand[] = { 1000, 1024 };
-	unsigned int modulo, decimals;
+	unsigned int modulo;
 	int unit_index = 0, post_index, carry = 0;
-	char tmp[32];
+	char tmp[32], fmt[32];
 	char *buf;
 
 	compiletime_assert(sizeof(sistr) == sizeof(iecstr), "unit prefix arrays must be identical sizes");
@@ -62,6 +62,9 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)
 		break;
 	}
 
+	/*
+	 * Divide by K/Ki until string length of num <= maxlen.
+	 */
 	modulo = -1U;
 	while (post_index < sizeof(sistr)) {
 		sprintf(tmp, "%llu", (unsigned long long) num);
@@ -74,6 +77,9 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)
 		post_index++;
 	}
 
+	/*
+	 * If no modulo, then we're done.
+	 */
 	if (modulo == -1U) {
 done:
 		if (post_index >= ARRAY_SIZE(sistr))
@@ -84,23 +90,25 @@ done:
 		return buf;
 	}
 
+	/*
+	 * If no room for decimals, then we're done.
+	 */
 	sprintf(tmp, "%llu", (unsigned long long) num);
-	decimals = maxlen - strlen(tmp);
-	if ((int)decimals <= 1) {
+	if ((int)(maxlen - strlen(tmp)) <= 1) {
 		if (carry)
 			num++;
 		goto done;
 	}
 
-	do {
-		sprintf(tmp, "%u", modulo);
-		if (strlen(tmp) <= decimals - 1)
-			break;
-
-		modulo = (modulo + 9) / 10;
-	} while (1);
+	/*
+	 * Fill in everything and return the result.
+	 */
+	assert(maxlen - strlen(tmp) - 1 > 0);
+	assert(modulo < thousand[!!pow2]);
+	sprintf(fmt, "%%.%df", (int)(maxlen - strlen(tmp) - 1));
+	sprintf(tmp, fmt, (double)modulo / (double)thousand[!!pow2]);
 
-	sprintf(buf, "%llu.%u%s%s", (unsigned long long) num, modulo,
+	sprintf(buf, "%llu.%s%s%s", (unsigned long long) num, &tmp[2],
 			unitprefix[post_index], unitstr[unit_index]);
 	return buf;
 }
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/9] Drop the only local variable declaration within a for-loop (C99)
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 1/9] Fix num2str() output when modulo != -1U kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 3/9] Make lib/strntol.c a stand-alone library kusumi.tomohiro
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

Nothing happens at least with gcc by default, but this is the only
C99 (or after) specific declaration, so change it to normal style.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 parse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/parse.c b/parse.c
index fd5605f..4d4fddd 100644
--- a/parse.c
+++ b/parse.c
@@ -135,6 +135,7 @@ static unsigned long long get_mult_time(const char *str, int len,
 	const char *p = str;
 	char *c;
 	unsigned long long mult = 1;
+	int i;
 
 	/*
          * Go forward until we hit a non-digit, or +/- sign
@@ -153,7 +154,7 @@ static unsigned long long get_mult_time(const char *str, int len,
 	}
 
 	c = strdup(p);
-	for (int i = 0; i < strlen(c); i++)
+	for (i = 0; i < strlen(c); i++)
 		c[i] = tolower(c[i]);
 
 	if (!strncmp("us", c, 2) || !strncmp("usec", c, 4))
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/9] Make lib/strntol.c a stand-alone library
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 1/9] Fix num2str() output when modulo != -1U kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 2/9] Drop the only local variable declaration within a for-loop (C99) kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 4/9] Make lib/pattern.c " kusumi.tomohiro
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

It needs to include strntol.h from local directory where strntol.c
is also located, to be able to use this as a stand-alone library,
which is useful for debugging purpose. In fact, most of the files
under lib/ directory do things this way.

--
 # cat ./test5.c
 #include <stdio.h>
 #include "lib/strntol.h"
 int main(void) {
         /* just to see if it compiles */
         strntol(NULL, 0, NULL, 0);
         return 0;
 }
 # gcc -Wall -g ./test5.c ./lib/strntol.c

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 lib/strntol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/strntol.c b/lib/strntol.c
index adf45bd..f622c8d 100644
--- a/lib/strntol.c
+++ b/lib/strntol.c
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <limits.h>
 
-#include "lib/strntol.h"
+#include "strntol.h"
 
 long strntol(const char *str, size_t sz, char **end, int base)
 {
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/9] Make lib/pattern.c a stand-alone library
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
                   ` (2 preceding siblings ...)
  2017-04-14 21:06 ` [PATCH 3/9] Make lib/strntol.c a stand-alone library kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 5/9] Make lib/rand.c " kusumi.tomohiro
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

lib/pattern.c not having dependency on fio.h enables it to be
a stand-alone library, which is useful for debugging purpose.
In fact, most of the files under lib/ directory do things this way.

This requires the previous commit.

--
 # cat ./test6.c
 #include <stdio.h>
 #include "lib/pattern.h"
 int main(void) {
         /* just to see if it compiles */
         paste_format_inplace(NULL, 0, NULL, 0, NULL);
         return 0;
 }
 # gcc -Wall -g ./test6.c ./lib/pattern.c ./lib/strntol.c

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 lib/pattern.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/pattern.c b/lib/pattern.c
index b8ae809..0aeb935 100644
--- a/lib/pattern.c
+++ b/lib/pattern.c
@@ -1,6 +1,13 @@
-#include "fio.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <errno.h>
+#include <assert.h>
+
 #include "strntol.h"
 #include "pattern.h"
+#include "../minmax.h"
 #include "../oslib/strcasestr.h"
 
 /**
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/9] Make lib/rand.c a stand-alone library
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
                   ` (3 preceding siblings ...)
  2017-04-14 21:06 ` [PATCH 4/9] Make lib/pattern.c " kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 6/9] Make lib/zipf.c " kusumi.tomohiro
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

It needs to include pattern.h from local directory where rand.c
is also located, to be able to use this as a stand-alone library,
which is useful for debugging purpose. In fact, most of the files
under lib/ directory do things this way.

--
 # cat ./test7.c
 #include <stdio.h>
 #include "lib/rand.h"
 int main(void) {
         /* just to see if it compiles */
         init_rand(NULL, 0);
         return 0;
 }
 # gcc -Wall -g -DBITS_PER_LONG=64 ./test7.c ./lib/rand.c ./lib/pattern.c ./lib/strntol.c

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 lib/rand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/rand.c b/lib/rand.c
index 9c3e0d6..3f60a67 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -36,7 +36,7 @@
 #include <string.h>
 #include <assert.h>
 #include "rand.h"
-#include "lib/pattern.h"
+#include "pattern.h"
 #include "../hash.h"
 
 int arch_random;
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/9] Make lib/zipf.c a stand-alone library
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
                   ` (4 preceding siblings ...)
  2017-04-14 21:06 ` [PATCH 5/9] Make lib/rand.c " kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 7/9] Make lib/mountcheck.c " kusumi.tomohiro
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

lib/zipf.c not having dependency on fio header (log.h) enables it
to be a stand-alone library, which is useful for debugging purpose.
In fact, most of the files under lib/ directory do things this way.

lib/zipf.c doesn't use log.h (log(3) is apparently from -lm).

This requires the previous commit.

--
 # cat ./test8.c
 #include <stdio.h>
 #include "lib/zipf.h"
 int main(void) {
         /* just to see if it compiles */
         zipf_init(NULL, 0, 0, 0);
         return 0;
 }
 # gcc -Wall -g -lm -DBITS_PER_LONG=64 ./test8.c ./lib/zipf.c ./lib/rand.c ./lib/pattern.c ./lib/strntol.c

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 lib/zipf.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/zipf.c b/lib/zipf.c
index 681df70..3d535c7 100644
--- a/lib/zipf.c
+++ b/lib/zipf.c
@@ -6,7 +6,6 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include "ieee754.h"
-#include "../log.h"
 #include "zipf.h"
 #include "../minmax.h"
 #include "../hash.h"
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 7/9] Make lib/mountcheck.c a stand-alone library
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
                   ` (5 preceding siblings ...)
  2017-04-14 21:06 ` [PATCH 6/9] Make lib/zipf.c " kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 8/9] Make oslib/strlcat.c " kusumi.tomohiro
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

It needs to include mountcheck.h from local directory where
mountcheck.c is also located, to be able to use this as
a stand-alone library, which is useful for debugging purpose.
In fact, most of the files under lib/ directory do things this way.

--
 # cat ./test11.c
 #include <stdio.h>
 #include "lib/mountcheck.h"
 int main(int argc, char **argv) {
         printf("%d\n", device_is_mounted(argv[1]));
         return 0;
 }

--
 # uname
 Linux
 # gcc -Wall -g -DCONFIG_GETMNTENT ./test11.c ./lib/mountcheck.c
 # ./a.out /dev/sda1
 1

--
 # uname
 DragonFly
 # gcc -Wall -g -DCONFIG_GETMNTINFO ./test11.c ./lib/mountcheck.c
 # ./a.out /dev/da0s1a
 1

--
 # uname
 NetBSD
 # gcc -Wall -g -DCONFIG_GETMNTINFO_STATVFS ./test11.c ./lib/mountcheck.c
 # ./a.out /dev/sd0a
 1

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 lib/mountcheck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mountcheck.c b/lib/mountcheck.c
index 0aec744..2fb6fe7 100644
--- a/lib/mountcheck.c
+++ b/lib/mountcheck.c
@@ -4,7 +4,7 @@
 #ifdef CONFIG_GETMNTENT
 #include <mntent.h>
 
-#include "lib/mountcheck.h"
+#include "mountcheck.h"
 
 #define MTAB	"/etc/mtab"
 
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 8/9] Make oslib/strlcat.c a stand-alone library
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
                   ` (6 preceding siblings ...)
  2017-04-14 21:06 ` [PATCH 7/9] Make lib/mountcheck.c " kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-14 21:06 ` [PATCH 9/9] Make oslib/linux-dev-lookup.c " kusumi.tomohiro
  2017-04-26 18:43 ` [PATCH 0/9] Jens Axboe
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

It needs to include strlcat.h from local directory where strlcat.c
is also located, to be able to use this as a stand-alone library,
which is useful for debugging purpose. In fact, most of the files
under oslib/ directory do things this way.

--
 # cat ./test9.c
 #include <stdio.h>
 #include "oslib/strlcat.h"
 int main(void) {
         /* just to see if it compiles */
         strlcat(NULL, NULL, 0);
         return 0;
 }
 # gcc -Wall -g ./test9.c ./oslib/strlcat.c

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 oslib/strlcat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/oslib/strlcat.c b/oslib/strlcat.c
index 3329b83..3b33d0e 100644
--- a/oslib/strlcat.c
+++ b/oslib/strlcat.c
@@ -1,5 +1,5 @@
 #include <string.h>
-#include "oslib/strlcat.h"
+#include "strlcat.h"
 
 size_t strlcat(char *dst, const char *src, size_t size)
 {
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 9/9] Make oslib/linux-dev-lookup.c a stand-alone library
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
                   ` (7 preceding siblings ...)
  2017-04-14 21:06 ` [PATCH 8/9] Make oslib/strlcat.c " kusumi.tomohiro
@ 2017-04-14 21:06 ` kusumi.tomohiro
  2017-04-26 18:43 ` [PATCH 0/9] Jens Axboe
  9 siblings, 0 replies; 11+ messages in thread
From: kusumi.tomohiro @ 2017-04-14 21:06 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

It needs to include linux-dev-lookup.h from local directory where
linux-dev-lookup.c is also located, to be able to use this as
a stand-alone library, which is useful for debugging purpose.
In fact, most of the files under oslib/ directory do things this way.

It also doesn't need to include os/os.h as it has no dependency.

--
 # cat ./test10.c
 #include <stdio.h>
 #include "oslib/linux-dev-lookup.h"
 int main(void) {
         /* just to see if it compiles */
         blktrace_lookup_device(NULL, NULL, 0, 0);
         return 0;
 }
 # gcc -Wall -g ./test10.c oslib/linux-dev-lookup.c

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 oslib/linux-dev-lookup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/oslib/linux-dev-lookup.c b/oslib/linux-dev-lookup.c
index 2bbd14a..5fbccd3 100644
--- a/oslib/linux-dev-lookup.c
+++ b/oslib/linux-dev-lookup.c
@@ -5,8 +5,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include "../os/os.h"
-#include "oslib/linux-dev-lookup.h"
+#include "linux-dev-lookup.h"
 
 int blktrace_lookup_device(const char *redirect, char *path, unsigned int maj,
 			   unsigned int min)
-- 
2.9.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/9]
  2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
                   ` (8 preceding siblings ...)
  2017-04-14 21:06 ` [PATCH 9/9] Make oslib/linux-dev-lookup.c " kusumi.tomohiro
@ 2017-04-26 18:43 ` Jens Axboe
  9 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2017-04-26 18:43 UTC (permalink / raw)
  To: kusumi.tomohiro; +Cc: fio, Tomohiro Kusumi

On Sat, Apr 15 2017, kusumi.tomohiro@gmail.com wrote:
> From: Tomohiro Kusumi <tkusumi@tuxera.com>
> 
> "Fix num2str() output when modulo != -1U" is a resend of below,
> which I believe has been neither acked nor nacked.
> http://www.spinics.net/lists/fio/msg05719.html
> 
> The patch is the same, but added a link to below comment to the commit message.
> http://www.spinics.net/lists/fio/msg05720.html

Applied, thanks.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-04-26 18:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-14 21:06 [PATCH 0/9] kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 1/9] Fix num2str() output when modulo != -1U kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 2/9] Drop the only local variable declaration within a for-loop (C99) kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 3/9] Make lib/strntol.c a stand-alone library kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 4/9] Make lib/pattern.c " kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 5/9] Make lib/rand.c " kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 6/9] Make lib/zipf.c " kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 7/9] Make lib/mountcheck.c " kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 8/9] Make oslib/strlcat.c " kusumi.tomohiro
2017-04-14 21:06 ` [PATCH 9/9] Make oslib/linux-dev-lookup.c " kusumi.tomohiro
2017-04-26 18:43 ` [PATCH 0/9] Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.