[PATCH] This commit fixes the following checkpatch.pl errors and warnings : >>ERROR: switch and case should be at the same indent + switch (whence) { + case 1: [...] + case 0: [...] + default:

Subsystems: filesystems (vfs and infrastructure), the rest

STALE1936d

2 messages, 2 authors, 2021-05-21 · open the first message on its own page

[PATCH] This commit fixes the following checkpatch.pl errors and warnings : >>ERROR: switch and case should be at the same indent + switch (whence) { + case 1: [...] + case 0: [...] + default:

From: aviral14112001 <hidden>
Date: 2021-05-21 05:48:23

quoted
ERROR: code indent should use tabs where possible
+                              void (*callback)(struct dentry *))$
quoted
WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
+			printk(KERN_WARNING "%s: %s passed in a files array"
quoted
WARNING: break quoted strings at a space character
+			printk(KERN_WARNING "%s: %s passed in a files array"
+				"with an index of 1!\n", __func__,
quoted
WARNING: Symbolic permissions 'S_IRUSR | S_IWUSR' are not preferred. Consider using octal permissions '0600'.
+	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
quoted
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
+			loff_t pos, unsigned len, unsigned flags,
quoted
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
+			loff_t pos, unsigned len, unsigned flags,
quoted
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
+		unsigned from = pos & (PAGE_SIZE - 1);
quoted
WARNING: Block comments use a trailing */ on a separate line
+ * to set the attribute specific access operations. */
quoted
WARNING: Symbolic permissions 'S_IRUGO | S_IXUGO' are not preferred. Consider using octal permissions '0555'.
+	inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
quoted
Several other warnings (WARNING: Missing a blank line after declarations)
Signed-off-by: aviral14112001 <redacted>
---
 fs/libfs.c | 66 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 29 deletions(-)
diff --git a/fs/libfs.c b/fs/libfs.c
index e9b29c6ffccb..a3b6bd803b7d 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -32,6 +32,7 @@ int simple_getattr(struct user_namespace *mnt_userns, const struct path *path,
 		   unsigned int query_flags)
 {
 	struct inode *inode = d_inode(path->dentry);
+
 	generic_fillattr(&init_user_ns, inode, stat);
 	stat->blocks = inode->i_mapping->nrpages << (PAGE_SHIFT - 9);
 	return 0;
@@ -137,16 +138,17 @@ static struct dentry *scan_positives(struct dentry *cursor,
 loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
 {
 	struct dentry *dentry = file->f_path.dentry;
+
 	switch (whence) {
-		case 1:
-			offset += file->f_pos;
-			fallthrough;
-		case 0:
-			if (offset >= 0)
-				break;
-			fallthrough;
-		default:
-			return -EINVAL;
+	case 1:
+		offset += file->f_pos;
+		fallthrough;
+	case 0:
+		if (offset >= 0)
+			break;
+		fallthrough;
+	default:
+		return -EINVAL;
 	}
 	if (offset != file->f_pos) {
 		struct dentry *cursor = file->private_data;
@@ -251,6 +253,7 @@ static struct dentry *find_next_child(struct dentry *parent, struct dentry *prev
 	spin_lock(&parent->d_lock);
 	while ((p = p->next) != &parent->d_subdirs) {
 		struct dentry *d = container_of(p, struct dentry, d_child);
+
 		if (simple_positive(d)) {
 			spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
 			if (simple_positive(d))
@@ -266,9 +269,10 @@ static struct dentry *find_next_child(struct dentry *parent, struct dentry *prev
 }
 
 void simple_recursive_removal(struct dentry *dentry,
-                              void (*callback)(struct dentry *))
+			void (*callback)(struct dentry *))
 {
 	struct dentry *this = dget(dentry);
+
 	while (true) {
 		struct dentry *victim = NULL, *child;
 		struct inode *inode = this->d_inode;
@@ -338,7 +342,7 @@ static int pseudo_fs_fill_super(struct super_block *s, struct fs_context *fc)
 	 * max_reserved of 1 to iunique).
 	 */
 	root->i_ino = 1;
-	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
+	root->i_mode = S_IFDIR | 0600;
 	root->i_atime = root->i_mtime = root->i_ctime = current_time(root);
 	s->s_root = d_make_root(root);
 	if (!s->s_root)
@@ -523,7 +527,7 @@ int simple_readpage(struct file *file, struct page *page)
 EXPORT_SYMBOL(simple_readpage);
 
 int simple_write_begin(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned flags,
+			loff_t pos, unsigned int len, unsigned int flags,
 			struct page **pagep, void **fsdata)
 {
 	struct page *page;
@@ -538,7 +542,7 @@ int simple_write_begin(struct file *file, struct address_space *mapping,
 	*pagep = page;
 
 	if (!PageUptodate(page) && (len != PAGE_SIZE)) {
-		unsigned from = pos & (PAGE_SIZE - 1);
+		unsigned int from = pos & (PAGE_SIZE - 1);
 
 		zero_user_segments(page, 0, from, from + len, PAGE_SIZE);
 	}
@@ -549,12 +553,12 @@ EXPORT_SYMBOL(simple_write_begin);
 /**
  * simple_write_end - .write_end helper for non-block-device FSes
  * @file: See .write_end of address_space_operations
- * @mapping: 		"
- * @pos: 		"
- * @len: 		"
- * @copied: 		"
- * @page: 		"
- * @fsdata: 		"
+ * @mapping:		"
+ * @pos:		"
+ * @len:		"
+ * @copied:		"
+ * @page:		"
+ * @fsdata:		"
  *
  * simple_write_end does the minimum needed for updating a page after writing is
  * done. It has the same API signature as the .write_end of
@@ -569,7 +573,7 @@ EXPORT_SYMBOL(simple_write_begin);
  * Use *ONLY* with simple_readpage()
  */
 int simple_write_end(struct file *file, struct address_space *mapping,
-			loff_t pos, unsigned len, unsigned copied,
+			loff_t pos, unsigned int len, unsigned int copied,
 			struct page *page, void *fsdata)
 {
 	struct inode *inode = page->mapping->host;
@@ -578,7 +582,7 @@ int simple_write_end(struct file *file, struct address_space *mapping,
 	/* zero the stale part of the page if we did a short copy */
 	if (!PageUptodate(page)) {
 		if (copied < len) {
-			unsigned from = pos & (PAGE_SIZE - 1);
+			unsigned int from = pos & (PAGE_SIZE - 1);
 
 			zero_user(page, from + copied, len - copied);
 		}
@@ -640,9 +644,8 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
 
 		/* warn if it tries to conflict with the root inode */
 		if (unlikely(i == 1))
-			printk(KERN_WARNING "%s: %s passed in a files array"
-				"with an index of 1!\n", __func__,
-				s->s_type->name);
+			pr_warn("%s: %s passed in a files array with an index of 1!\n"
+			, __func__, s->s_type->name);
 
 		dentry = d_alloc_name(root, files->name);
 		if (!dentry)
@@ -673,6 +676,7 @@ static DEFINE_SPINLOCK(pin_fs_lock);
 int simple_pin_fs(struct file_system_type *type, struct vfsmount **mount, int *count)
 {
 	struct vfsmount *mnt = NULL;
+
 	spin_lock(&pin_fs_lock);
 	if (unlikely(!*mount)) {
 		spin_unlock(&pin_fs_lock);
@@ -694,6 +698,7 @@ EXPORT_SYMBOL(simple_pin_fs);
 void simple_release_fs(struct vfsmount **mount, int *count)
 {
 	struct vfsmount *mnt;
+
 	spin_lock(&pin_fs_lock);
 	mnt = *mount;
 	if (!--*count)
@@ -888,8 +893,10 @@ struct simple_attr {
 	struct mutex mutex;	/* protects access to these buffers */
 };
 
-/* simple_attr_open is called by an actual attribute open file operation
- * to set the attribute specific access operations. */
+/*
+ * simple_attr_open is called by an actual attribute open file operation
+ * to set the attribute specific access operations.
+ */
 int simple_attr_open(struct inode *inode, struct file *file,
 		     int (*get)(void *, u64 *), int (*set)(void *, u64),
 		     const char *fmt)
@@ -1133,7 +1140,7 @@ EXPORT_SYMBOL(generic_file_fsync);
  * block size of 2**@blocksize_bits) is addressable by the sector_t
  * and page cache of the system.  Return 0 if so and -EFBIG otherwise.
  */
-int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
+int generic_check_addressable(unsigned int blocksize_bits, u64 num_blocks)
 {
 	u64 last_fs_block = num_blocks - 1;
 	u64 last_fs_page =
@@ -1237,7 +1244,7 @@ struct inode *alloc_anon_inode(struct super_block *s)
 	 * that it already _is_ on the dirty list.
 	 */
 	inode->i_state = I_DIRTY;
-	inode->i_mode = S_IRUSR | S_IWUSR;
+	inode->i_mode = 0600;
 	inode->i_uid = current_fsuid();
 	inode->i_gid = current_fsgid();
 	inode->i_flags |= S_PRIVATE;
@@ -1303,6 +1310,7 @@ static int empty_dir_getattr(struct user_namespace *mnt_userns,
 			     u32 request_mask, unsigned int query_flags)
 {
 	struct inode *inode = d_inode(path->dentry);
+
 	generic_fillattr(&init_user_ns, inode, stat);
 	return 0;
 }
@@ -1349,7 +1357,7 @@ static const struct file_operations empty_dir_operations = {
 void make_empty_dir_inode(struct inode *inode)
 {
 	set_nlink(inode, 2);
-	inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
+	inode->i_mode = S_IFDIR | 0555;
 	inode->i_uid = GLOBAL_ROOT_UID;
 	inode->i_gid = GLOBAL_ROOT_GID;
 	inode->i_rdev = 0;
-- 
2.25.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

Re: [PATCH] This commit fixes the following checkpatch.pl errors and warnings : >>ERROR: switch and case should be at the same indent + switch (whence) { + case 1: [...] + case 0: [...] + default:

From: Greg KH <gregkh@linuxfoundation.org>
Date: 2021-05-21 06:49:01

On Fri, May 21, 2021 at 11:18:57AM +0530, aviral14112001 wrote:
quoted
quoted
ERROR: code indent should use tabs where possible
+                              void (*callback)(struct dentry *))$
quoted
quoted
WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then dev_warn(dev, ... then pr_warn(...  to printk(KERN_WARNING ...
+			printk(KERN_WARNING "%s: %s passed in a files array"
quoted
quoted
WARNING: break quoted strings at a space character
+			printk(KERN_WARNING "%s: %s passed in a files array"
+				"with an index of 1!\n", __func__,
quoted
quoted
WARNING: Symbolic permissions 'S_IRUSR | S_IWUSR' are not preferred. Consider using octal permissions '0600'.
+	root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
quoted
quoted
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
+			loff_t pos, unsigned len, unsigned flags,
quoted
quoted
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
+			loff_t pos, unsigned len, unsigned flags,
quoted
quoted
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
+		unsigned from = pos & (PAGE_SIZE - 1);
quoted
quoted
WARNING: Block comments use a trailing */ on a separate line
+ * to set the attribute specific access operations. */
quoted
quoted
WARNING: Symbolic permissions 'S_IRUGO | S_IXUGO' are not preferred. Consider using octal permissions '0555'.
+	inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
quoted
quoted
Several other warnings (WARNING: Missing a blank line after declarations)
Signed-off-by: aviral14112001 <redacted>
---
 fs/libfs.c | 66 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 29 deletions(-)
Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch did many different things all at once, making it difficult
  to review.  All Linux kernel patches need to only do one thing at a
  time.  If you need to do multiple things (such as clean up all coding
  style issues in a file/driver), do it in a sequence of patches, each
  one doing only one thing.  This will make it easier to review the
  patches to ensure that they are correct, and to help alleviate any
  merge issues that larger patches can cause.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what is needed in order to
  properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what a proper Subject: line should
  look like.

- It looks like you did not use your "real" name for the patch on either
  the Signed-off-by: line, or the From: line (both of which have to
  match).  Please read the kernel file, Documentation/SubmittingPatches
  for how to do this correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help