Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH 0/3] null ioengine fix
@ 2018-01-15 19:52 kusumi.tomohiro
  2018-01-15 19:52 ` [PATCH 1/3] null: fix compile time warning on OpenBSD kusumi.tomohiro
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: kusumi.tomohiro @ 2018-01-15 19:52 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

Resending these as I forgot to add signed-off-by, sorry.

Tomohiro Kusumi (3):
  null: fix compile time warning on OpenBSD
  null: make *impl_ private
  null: drop unneeded casts from void* to non-void*

 engines/null.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

-- 
2.13.6



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

* [PATCH 1/3] null: fix compile time warning on OpenBSD
  2018-01-15 19:52 [PATCH 0/3] null ioengine fix kusumi.tomohiro
@ 2018-01-15 19:52 ` kusumi.tomohiro
  2018-01-15 19:52 ` [PATCH 2/3] null: make *impl_ private kusumi.tomohiro
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: kusumi.tomohiro @ 2018-01-15 19:52 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

Fix the following warning on OpenBSD 6.2 (gcc 4.2.1).
This can probably be silenced with void** argument and memcpy() too,
but returning a non-void pointer is clearer IMO when the code also
targets C++.

Compiles with regular make/gmake as well as
 # g++ -O2 -g -shared -rdynamic -fPIC -o cpp_null null.c -DFIO_EXTERNAL_ENGINE

--
    CC engines/null.o
engines/null.c: In function 'fio_null_init':
engines/null.c:142: warning: dereferencing type-punned pointer will break strict-aliasing rules

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 engines/null.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/engines/null.c b/engines/null.c
index 8a4d106b..47f29054 100644
--- a/engines/null.c
+++ b/engines/null.c
@@ -87,9 +87,9 @@ static void null_cleanup(struct null_data *nd)
 	}
 }
 
-static int null_init(struct thread_data *td, struct null_data **nd_ptr)
+static struct null_data *null_init(struct thread_data *td)
 {
-	struct null_data *nd = (struct null_data *) malloc(sizeof(**nd_ptr));
+	struct null_data *nd = (struct null_data *) malloc(sizeof(*nd));
 
 	memset(nd, 0, sizeof(*nd));
 
@@ -99,8 +99,7 @@ static int null_init(struct thread_data *td, struct null_data **nd_ptr)
 	} else
 		td->io_ops->flags |= FIO_SYNCIO;
 
-	*nd_ptr = nd;
-	return 0;
+	return nd;
 }
 
 #ifndef __cplusplus
@@ -139,7 +138,9 @@ static void fio_null_cleanup(struct thread_data *td)
 
 static int fio_null_init(struct thread_data *td)
 {
-	return null_init(td, (struct null_data **)&td->io_ops_data);
+	td->io_ops_data = null_init(td);
+	assert(td->io_ops_data);
+	return 0;
 }
 
 static struct ioengine_ops ioengine = {
@@ -172,7 +173,8 @@ static void fio_exit fio_null_unregister(void)
 struct NullData {
 	NullData(struct thread_data *td)
 	{
-		null_init(td, &impl_);
+		impl_ = null_init(td);
+		assert(impl_);
 	}
 
 	~NullData()
-- 
2.13.6



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

* [PATCH 2/3] null: make *impl_ private
  2018-01-15 19:52 [PATCH 0/3] null ioengine fix kusumi.tomohiro
  2018-01-15 19:52 ` [PATCH 1/3] null: fix compile time warning on OpenBSD kusumi.tomohiro
@ 2018-01-15 19:52 ` kusumi.tomohiro
  2018-01-15 19:52 ` [PATCH 3/3] null: drop unneeded casts from void* to non-void* kusumi.tomohiro
  2018-01-16 15:33 ` [PATCH 0/3] null ioengine fix Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: kusumi.tomohiro @ 2018-01-15 19:52 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

This can/should be private, given struct is default public in C++.
The null ioengine only needs access to new'd NullData which
encapsulates malloc'd null_data *impl_.

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

diff --git a/engines/null.c b/engines/null.c
index 47f29054..cf1ee1f2 100644
--- a/engines/null.c
+++ b/engines/null.c
@@ -213,6 +213,7 @@ struct NullData {
 		return null_open(impl_, f);
 	}
 
+private:
 	struct null_data *impl_;
 };
 
-- 
2.13.6



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

* [PATCH 3/3] null: drop unneeded casts from void* to non-void*
  2018-01-15 19:52 [PATCH 0/3] null ioengine fix kusumi.tomohiro
  2018-01-15 19:52 ` [PATCH 1/3] null: fix compile time warning on OpenBSD kusumi.tomohiro
  2018-01-15 19:52 ` [PATCH 2/3] null: make *impl_ private kusumi.tomohiro
@ 2018-01-15 19:52 ` kusumi.tomohiro
  2018-01-16 15:33 ` [PATCH 0/3] null ioengine fix Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: kusumi.tomohiro @ 2018-01-15 19:52 UTC (permalink / raw)
  To: axboe, fio; +Cc: Tomohiro Kusumi

From: Tomohiro Kusumi <tkusumi@tuxera.com>

Some functions in null ioengine are used by C/C++ (e.g. null_init()
which calls malloc(3)), but C specific ones (not __cplusplus) don't
need explicit cast from void* to non-void*, and one usually doesn't.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 engines/null.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/engines/null.c b/engines/null.c
index cf1ee1f2..0cfc22ad 100644
--- a/engines/null.c
+++ b/engines/null.c
@@ -106,34 +106,34 @@ static struct null_data *null_init(struct thread_data *td)
 
 static struct io_u *fio_null_event(struct thread_data *td, int event)
 {
-	return null_event((struct null_data *)td->io_ops_data, event);
+	return null_event(td->io_ops_data, event);
 }
 
 static int fio_null_getevents(struct thread_data *td, unsigned int min_events,
 			      unsigned int max, const struct timespec *t)
 {
-	struct null_data *nd = (struct null_data *)td->io_ops_data;
+	struct null_data *nd = td->io_ops_data;
 	return null_getevents(nd, min_events, max, t);
 }
 
 static int fio_null_commit(struct thread_data *td)
 {
-	return null_commit(td, (struct null_data *)td->io_ops_data);
+	return null_commit(td, td->io_ops_data);
 }
 
 static int fio_null_queue(struct thread_data *td, struct io_u *io_u)
 {
-	return null_queue(td, (struct null_data *)td->io_ops_data, io_u);
+	return null_queue(td, td->io_ops_data, io_u);
 }
 
 static int fio_null_open(struct thread_data *td, struct fio_file *f)
 {
-	return null_open((struct null_data *)td->io_ops_data, f);
+	return null_open(td->io_ops_data, f);
 }
 
 static void fio_null_cleanup(struct thread_data *td)
 {
-	null_cleanup((struct null_data *)td->io_ops_data);
+	null_cleanup(td->io_ops_data);
 }
 
 static int fio_null_init(struct thread_data *td)
-- 
2.13.6



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

* Re: [PATCH 0/3] null ioengine fix
  2018-01-15 19:52 [PATCH 0/3] null ioengine fix kusumi.tomohiro
                   ` (2 preceding siblings ...)
  2018-01-15 19:52 ` [PATCH 3/3] null: drop unneeded casts from void* to non-void* kusumi.tomohiro
@ 2018-01-16 15:33 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2018-01-16 15:33 UTC (permalink / raw)
  To: kusumi.tomohiro, fio; +Cc: Tomohiro Kusumi

On 1/15/18 12:52 PM, kusumi.tomohiro@gmail.com wrote:
> From: Tomohiro Kusumi <tkusumi@tuxera.com>
> 
> Resending these as I forgot to add signed-off-by, sorry.
> 
> Tomohiro Kusumi (3):
>   null: fix compile time warning on OpenBSD
>   null: make *impl_ private
>   null: drop unneeded casts from void* to non-void*

Thanks, applied.

-- 
Jens Axboe



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

end of thread, other threads:[~2018-01-16 15:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 19:52 [PATCH 0/3] null ioengine fix kusumi.tomohiro
2018-01-15 19:52 ` [PATCH 1/3] null: fix compile time warning on OpenBSD kusumi.tomohiro
2018-01-15 19:52 ` [PATCH 2/3] null: make *impl_ private kusumi.tomohiro
2018-01-15 19:52 ` [PATCH 3/3] null: drop unneeded casts from void* to non-void* kusumi.tomohiro
2018-01-16 15:33 ` [PATCH 0/3] null ioengine fix Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox