Skip to contentSkip to conversation

jbd/jbd2: add pointer type conversion on void *arg from void * to journal_t * explicitly in kjournald/kjournald2

PATCH In review Wang Sheng-Hui 5 participants 8 messages Aug 3, 2011 Journalling layer for block devices (JBD2)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd/jbd2: add pointer type conversion on void *arg from void * to journal_t * explicitly in kjournald/kjournald2

The patch is against 3.0

The arg of kjournald/kjournald2 is void *, and points to type journal_t. We should convert it to journal_t * explicitly in the kjournald/kjournald2 function body.

---
 fs/jbd/journal.c  |    2 +-
 fs/jbd2/journal.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/jbd/journal.c +1 -1
index e2d4285..32956fd 100644
@@ -116,7 +116,7 @@ static void commit_timeout(unsigned long __data)
 
 static int kjournald(void *arg)
 {
-	journal_t *journal = arg;
+	journal_t *journal = (journal_t *)arg;
 	transaction_t *transaction;
 
 	/*
fs/jbd2/journal.c +1 -1
index 0dfa5b5..c4f4bfc 100644
@@ -129,7 +129,7 @@ static void commit_timeout(unsigned long __data)
 
 static int kjournald2(void *arg)
 {
-	journal_t *journal = arg;
+	journal_t *journal = (journal_t *)arg;
 	transaction_t *transaction;
 
 	/*
Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Wang Sheng-Hui

The patch is against 3.0

The arg of kjournald/kjournald2 is void *, and points to type journal_t. We should convert it to journal_t * explicitly in the kjournald/kjournald2 function body.

Why?

Implicit convertion from void * to foo * is ok. Did the compiler complain about this to you?

Quoted 32 lines
---
 fs/jbd/journal.c  |    2 +-
 fs/jbd2/journal.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/jbd/journal.c +1 -1
index e2d4285..32956fd 100644
@@ -116,7 +116,7 @@ static void commit_timeout(unsigned long __data)
 
 static int kjournald(void *arg)
 {
-	journal_t *journal = arg;
+	journal_t *journal = (journal_t *)arg;
 	transaction_t *transaction;
 
 	/*
fs/jbd2/journal.c +1 -1
index 0dfa5b5..c4f4bfc 100644
@@ -129,7 +129,7 @@ static void commit_timeout(unsigned long __data)
 
 static int kjournald2(void *arg)
 {
-	journal_t *journal = arg;
+	journal_t *journal = (journal_t *)arg;
 	transaction_t *transaction;
 
 	/*
#2 lore raw
Quoted 8 lines · Li Zefan
Quoted 6 lines · Wang Sheng-Hui

The patch is against 3.0

The arg of kjournald/kjournald2 is void *, and points to type journal_t. We should convert it to journal_t * explicitly in the kjournald/kjournald2 function body.

Quoted 4 lines

Why?

Implicit convertion from void * to foo * is ok. Did the compiler complain about this to you?

I remember any * can be assigned directly to void * in ANSI C, but void * should be converted to specific point * type. Right?

And I checked the code of kswapd, in which explicitly conversion is taken on the arg *. I think it should do so in journal.c too.

Quoted 26 lines
Quoted 26 lines
---
 fs/jbd/journal.c  |    2 +-
 fs/jbd2/journal.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/jbd/journal.c +1 -1
index e2d4285..32956fd 100644
@@ -116,7 +116,7 @@ static void commit_timeout(unsigned long __data)
 
 static int kjournald(void *arg)
 {
-	journal_t *journal = arg;
+	journal_t *journal = (journal_t *)arg;
 	transaction_t *transaction;
 
 	/*
fs/jbd2/journal.c +0 -0
index 0dfa5b5..c4f4bfc 100644
@@ -129,7 +129,7 @@ static void commit_timeout(unsigned long __data)
 
Quoted 7 lines

fs/jbd2/journal.c static void commit_timeout(unsigned long __data) · line 135

Quoted 7 lines
fs/jbd2/journal.c +1 -1
 static int kjournald2(void *arg)
 {
-	journal_t *journal = arg;
+	journal_t *journal = (journal_t *)arg;
 	transaction_t *transaction;
 
 	/*

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 9 lines · Wang Sheng-Hui
Quoted 8 lines · Li Zefan
Quoted 6 lines · Wang Sheng-Hui

The patch is against 3.0

The arg of kjournald/kjournald2 is void *, and points to type journal_t. We should convert it to journal_t * explicitly in the kjournald/kjournald2 function body.

Quoted 8 lines
Quoted 4 lines

Why?

Implicit convertion from void * to foo * is ok. Did the compiler complain about this to you?

I remember any * can be assigned directly to void * in ANSI C, but void * should be converted to specific point * type. Right?

No.

Quoted 3 lines

And I checked the code of kswapd, in which explicitly conversion is taken on the arg *. I think it should do so in journal.c too.

Please check more similar code.
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Wang Sheng-Hui
Quoted 4 lines · Wang Sheng-Hui

I remember any * can be assigned directly to void * in ANSI C, but void * should be converted to specific point * type. Right?

C99 6.3.2.3

A pointer to void may be converted to or from a pointer to any incomplete or object
type. A pointer to any incomplete or object type may be converted to a pointer to void
and back again; the result shall compare equal to the original pointer.

#5 lore raw
Quoted 7 lines · Américo Wang
Quoted 4 lines · Wang Sheng-Hui

I remember any * can be assigned directly to void * in ANSI C, but void * should be converted to specific point * type. Right?

C99 6.3.2.3

Got it. Thanks,

Quoted 6 lines

A pointer to void may be converted to or from a pointer to any incomplete or object
type. A pointer to any incomplete or object type may be converted to a pointer to void
and back again; the result shall compare equal to the original pointer.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to Wang Sheng-Hui

Hi,

Quoted 3 lines · Wang Sheng-Hui

And I checked the code of kswapd, in which explicitly conversion is taken on the arg *. I think it should do so in journal.c too.

because it is done wrong somewhere is no argument to do it wrong here ...

- Arnaud

#7 lore raw
In reply to Li Zefan
Quoted 8 lines · Li Zefan
Quoted 6 lines · Wang Sheng-Hui

The patch is against 3.0

The arg of kjournald/kjournald2 is void *, and points to type journal_t. We should convert it to journal_t * explicitly in the kjournald/kjournald2 function body.

Quoted 5 lines

Why?

Implicit convertion from void * to foo * is ok. Did the compiler complain about this to you?

Not only is it perfectly OK to rely on the implicit conversion, a lot of work has gone into actively removing such unneeded explicit casts over the years, so let's not introduce new ones.

Signature · 3 lines
Jesper Juhl <[email protected]>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.