Skip to contentSkip to conversation

fs: Add function declaration of simple_dname

PATCH In review Leon Romanovsky 2 participants 5 messages Aug 19, 2020 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: Add function declaration of simple_dname

From: Leon Romanovsky <[email protected]>

The simple_dname() is declared in internal header file as extern and this generates the following GCC warning.

fs/d_path.c:311:7: warning: no previous prototype for 'simple_dname' [-Wmissing-prototypes]
311 | char *simple_dname(struct dentry *dentry, char *buffer, int buflen)

      |       ^~~~~~~~~~~~

Instead of that extern, reuse the fact that internal.h file is internal to fs/* and declare simple_dname() like any other function.

Fixes 7e5f7bb08b8c ("unexport simple_dname()")
---
 fs/d_path.c   | 2 ++
 fs/internal.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
fs/d_path.c +2 -0
index 0f1fc1743302..4b89448cc78e 100644
@@ -8,6 +8,8 @@
 #include <linux/prefetch.h>
 #include "mount.h"
 
+#include "internal.h"
+
 static int prepend(char **buffer, int *buflen, const char *str, int namelen)
 {
 	*buflen -= namelen;
fs/internal.h +1 -1
index 10517ece4516..2def264272f4 100644
@@ -164,7 +164,7 @@ extern int d_set_mounted(struct dentry *dentry);
 extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
 extern struct dentry *d_alloc_cursor(struct dentry *);
 extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
-extern char *simple_dname(struct dentry *, char *, int);
+char *simple_dname(struct dentry *d, char *buf, int len);
 extern void dput_to_list(struct dentry *, struct list_head *);
 extern void shrink_dentry_list(struct list_head *);
 

--
2.26.2

#1 lore raw
Quoted 4 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

The simple_dname() is declared in internal header file as extern and this generates the following GCC warning.

The fact that it's declared as extern doesn't matter. You don't need the change to internal.h at all. The use of 'extern' on a function declaration is purely decorative:

5 If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern.

I'd drop the change to internal.h and fix the changelog.

Quoted 43 lines

fs/d_path.c:311:7: warning: no previous prototype for 'simple_dname' [-Wmissing-prototypes]
311 | char *simple_dname(struct dentry *dentry, char *buffer, int buflen)

      |       ^~~~~~~~~~~~

Instead of that extern, reuse the fact that internal.h file is internal to fs/* and declare simple_dname() like any other function.

Fixes 7e5f7bb08b8c ("unexport simple_dname()")
---
 fs/d_path.c   | 2 ++
 fs/internal.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
fs/d_path.c +2 -0
index 0f1fc1743302..4b89448cc78e 100644
@@ -8,6 +8,8 @@
 #include <linux/prefetch.h>
 #include "mount.h"
 
+#include "internal.h"
+
 static int prepend(char **buffer, int *buflen, const char *str, int namelen)
 {
 	*buflen -= namelen;
fs/internal.h +1 -2
index 10517ece4516..2def264272f4 100644
@@ -164,7 +164,7 @@ extern int d_set_mounted(struct dentry *dentry);
 extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
 extern struct dentry *d_alloc_cursor(struct dentry *);
 extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
-extern char *simple_dname(struct dentry *, char *, int);
+char *simple_dname(struct dentry *d, char *buf, int len);
 extern void dput_to_list(struct dentry *, struct list_head *);
 extern void shrink_dentry_list(struct list_head *);
 
--

2.26.2

#2 lore raw
Quoted 6 lines · Matthew Wilcox
Quoted 4 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

The simple_dname() is declared in internal header file as extern and this generates the following GCC warning.

Quoted 7 lines

The fact that it's declared as extern doesn't matter. You don't need the change to internal.h at all. The use of 'extern' on a function declaration is purely decorative:

5 If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern.

So why do we need to keep extern keyword if we use intenral.h directly?

Quoted 2 lines

I'd drop the change to internal.h and fix the changelog.

Thanks

Quoted 44 lines
Quoted 44 lines

fs/d_path.c:311:7: warning: no previous prototype for 'simple_dname' [-Wmissing-prototypes]
311 | char *simple_dname(struct dentry *dentry, char *buffer, int buflen)

      |       ^~~~~~~~~~~~

Instead of that extern, reuse the fact that internal.h file is internal to fs/* and declare simple_dname() like any other function.

Fixes 7e5f7bb08b8c ("unexport simple_dname()")
---
 fs/d_path.c   | 2 ++
 fs/internal.h | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
fs/d_path.c +2 -0
index 0f1fc1743302..4b89448cc78e 100644
@@ -8,6 +8,8 @@
 #include <linux/prefetch.h>
 #include "mount.h"
 
+#include "internal.h"
+
 static int prepend(char **buffer, int *buflen, const char *str, int namelen)
 {
 	*buflen -= namelen;
fs/internal.h +1 -2
index 10517ece4516..2def264272f4 100644
@@ -164,7 +164,7 @@ extern int d_set_mounted(struct dentry *dentry);
 extern long prune_dcache_sb(struct super_block *sb, struct shrink_control *sc);
 extern struct dentry *d_alloc_cursor(struct dentry *);
 extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
-extern char *simple_dname(struct dentry *, char *, int);
+char *simple_dname(struct dentry *d, char *buf, int len);
 extern void dput_to_list(struct dentry *, struct list_head *);
 extern void shrink_dentry_list(struct list_head *);
 
--

2.26.2

#3 lore raw
Quoted 11 lines · Leon Romanovsky
Quoted 10 lines · Matthew Wilcox
Quoted 4 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

The simple_dname() is declared in internal header file as extern and this generates the following GCC warning.

The fact that it's declared as extern doesn't matter. You don't need the change to internal.h at all. The use of 'extern' on a function declaration is purely decorative:

Quoted 5 lines
Quoted 3 lines

5 If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern.

So why do we need to keep extern keyword if we use intenral.h directly?

We don't. It's just personal preference. I don't use extern keywords on function declarations anywhere, but Al does and it's rude to change it.

#4 lore raw
Quoted 12 lines · Matthew Wilcox
Quoted 11 lines · Leon Romanovsky
Quoted 10 lines · Matthew Wilcox
Quoted 4 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

The simple_dname() is declared in internal header file as extern and this generates the following GCC warning.

The fact that it's declared as extern doesn't matter. You don't need the change to internal.h at all. The use of 'extern' on a function declaration is purely decorative:

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

5 If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern.

So why do we need to keep extern keyword if we use intenral.h directly?

We don't. It's just personal preference. I don't use extern keywords on function declarations anywhere, but Al does and it's rude to change it.

I didn't have any intention to be rude, just like you, I don't use extern keyword.

I'll resend to make a progress.

Thanks

Quoted 1 line