Skip to contentSkip to conversation

xfs: don't allow negative error tags

PATCH In review Dan Carpenter 2 participants 4 messages Jun 24, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: don't allow negative error tags

Errors go from zero which means no error to XFS_ERRTAG_MAX (22). My static checker complains that xfs_errortag_add() puts an upper bound on this but not a lower bound. Let's fix it by making it unsigned.

fs/xfs/xfs_error.h +1 -1
index 4ed3042..2e4f67f 100644
@@ -128,7 +128,7 @@ extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
 	 xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \
 			(rf))))
 
-extern int xfs_errortag_add(int error_tag, struct xfs_mount *mp);
+extern int xfs_errortag_add(unsigned int error_tag, struct xfs_mount *mp);
 extern int xfs_errortag_clearall(struct xfs_mount *mp, int loud);
 #else
 #define XFS_TEST_ERROR(expr, mp, tag, rf)	(expr)
fs/xfs/xfs_error.c +1 -1
index 355619a..ed7ee4e 100644
@@ -55,7 +55,7 @@ xfs_error_test(int error_tag, int *fsidp, char *expression,
 }
 
 int
-xfs_errortag_add(int error_tag, xfs_mount_t *mp)
+xfs_errortag_add(unsigned int error_tag, xfs_mount_t *mp)
 {
 	int i;
 	int len;
#1 lore raw

Hi Dan,

xfs_errortag_add() is called by xfs_file_ioctl(), which accept the 1st argument as signed, i.e,

typedef struct xfs_error_injection {
__s32 fd;
__s32 errtag;
} xfs_error_injection_t;

Should we make it happy as well? Also, the typedef can be converted to to struct xfs_error_injection by removing the depreciated xfs_error_injection_t
syntax if so.

On 2016年06月24日 20:22, Dan Carpenter wrote:

Errors go from zero which means no error to XFS_ERRTAG_MAX (22). My static checker complains that xfs_errortag_add() puts an upper bound on this but not a lower bound. Let's fix it by making it unsigned.

fs/xfs/xfs_error.h +1 -1
index 4ed3042..2e4f67f 100644
@@ -128,7 +128,7 @@ extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
 	 xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \
 			(rf))))
 
-extern int xfs_errortag_add(int error_tag, struct xfs_mount *mp);
+extern int xfs_errortag_add(unsigned int error_tag, struct xfs_mount *mp);
 extern int xfs_errortag_clearall(struct xfs_mount *mp, int loud);
 #else
 #define XFS_TEST_ERROR(expr, mp, tag, rf)	(expr)
fs/xfs/xfs_error.c +1 -1
index 355619a..ed7ee4e 100644
@@ -55,7 +55,7 @@ xfs_error_test(int error_tag, int *fsidp, char *expression,
 }
 
 int
-xfs_errortag_add(int error_tag, xfs_mount_t *mp)
+xfs_errortag_add(unsigned int error_tag, xfs_mount_t *mp)
 {
 	int i;
 	int len;

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Signature · 3 lines
Cheers,

Jeff Liu
#2 lore raw
Quoted 10 lines · Jeff Liu

Hi Dan,

xfs_errortag_add() is called by xfs_file_ioctl(), which accept the 1st argument as signed, i.e,

typedef struct xfs_error_injection {
__s32 fd;
__s32 errtag;
} xfs_error_injection_t;

Quoted 4 lines

Should we make it happy as well? Also, the typedef can be converted to to struct xfs_error_injection by removing the depreciated xfs_error_injection_t
syntax if so.

That has been the user interface for a while so I didn't want to change it.

regards,
dan carpenter

#3 lore raw
In reply to Dan Carpenter

Hi Dan,

xfs_errortag_add() is called by xfs_file_ioctl(), which accept the 1st argument as signed, i.e,

typedef struct xfs_error_injection {
__s32 fd;
__s32 errtag;
} xfs_error_injection_t;

Should we make it happy as well? Also, the typedef can be converted to to struct xfs_error_injection by removing the depreciated xfs_error_injection_t
syntax if so.

On 2016年06月24日 20:22, Dan Carpenter wrote:

Errors go from zero which means no error to XFS_ERRTAG_MAX (22). My static checker complains that xfs_errortag_add() puts an upper bound on this but not a lower bound. Let's fix it by making it unsigned.

fs/xfs/xfs_error.h +1 -1
index 4ed3042..2e4f67f 100644
@@ -128,7 +128,7 @@ extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
 	 xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \
 			(rf))))
 
-extern int xfs_errortag_add(int error_tag, struct xfs_mount *mp);
+extern int xfs_errortag_add(unsigned int error_tag, struct xfs_mount *mp);
 extern int xfs_errortag_clearall(struct xfs_mount *mp, int loud);
 #else
 #define XFS_TEST_ERROR(expr, mp, tag, rf)	(expr)
fs/xfs/xfs_error.c +1 -1
index 355619a..ed7ee4e 100644
@@ -55,7 +55,7 @@ xfs_error_test(int error_tag, int *fsidp, char *expression,
 }
 
 int
-xfs_errortag_add(int error_tag, xfs_mount_t *mp)
+xfs_errortag_add(unsigned int error_tag, xfs_mount_t *mp)
 {
 	int i;
 	int len;

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Signature · 3 lines
Cheers,

Jeff Liu