All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] [SCSI] target: dubious one-bit signed bitfield
@ 2011-01-15 14:04 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-01-15 14:04 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: James Bottomley, linux-kernel, linux-scsi, kernel-janitors

The signed one-bit types can be 0 or -1 which can cause a problem if
someone ever checks if (foo->lu_gp_assoc == 1).  The current code is
fine because everyone just checks zero vs non-zero.  But Sparse
complains about it so lets change it.  The warnings look like this:

include/target/target_core_base.h:228:26: error: dubious one-bit signed bitfield

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 07fdfb6..764177b 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -225,7 +225,7 @@ struct t10_alua_lu_gp {
 } ____cacheline_aligned;
 
 struct t10_alua_lu_gp_member {
-	int lu_gp_assoc:1;
+	bool lu_gp_assoc;
 	atomic_t lu_gp_mem_ref_cnt;
 	spinlock_t lu_gp_mem_lock;
 	struct t10_alua_lu_gp *lu_gp;
@@ -257,7 +257,7 @@ struct t10_alua_tg_pt_gp {
 } ____cacheline_aligned;
 
 struct t10_alua_tg_pt_gp_member {
-	int tg_pt_gp_assoc:1;
+	bool tg_pt_gp_assoc;
 	atomic_t tg_pt_gp_mem_ref_cnt;
 	spinlock_t tg_pt_gp_mem_lock;
 	struct t10_alua_tg_pt_gp *tg_pt_gp;
@@ -322,7 +322,7 @@ struct t10_pr_registration {
 	int pr_res_type;
 	int pr_res_scope;
 	/* Used for fabric initiator WWPNs using a ISID */
-	int isid_present_at_reg:1;
+	bool isid_present_at_reg;
 	u32 pr_res_mapped_lun;
 	u32 pr_aptpl_target_lun;
 	u32 pr_res_generation;
@@ -404,7 +404,7 @@ struct se_transport_task {
 	unsigned long long	t_task_lba;
 	int			t_tasks_failed;
 	int			t_tasks_fua;
-	int			t_tasks_bidi:1;
+	bool			t_tasks_bidi;
 	u32			t_task_cdbs;
 	u32			t_tasks_check;
 	u32			t_tasks_no;
@@ -456,7 +456,7 @@ struct se_task {
 	u8		task_flags;
 	int		task_error_status;
 	int		task_state_flags;
-	int		task_padded_sg:1;
+	bool		task_padded_sg;
 	unsigned long long	task_lba;
 	u32		task_no;
 	u32		task_sectors;
@@ -569,7 +569,7 @@ struct se_ua {
 struct se_node_acl {
 	char			initiatorname[TRANSPORT_IQN_LEN];
 	/* Used to signal demo mode created ACL, disabled by default */
-	int			dynamic_node_acl:1;
+	bool			dynamic_node_acl;
 	u32			queue_depth;
 	u32			acl_index;
 	u64			num_cmds;
@@ -622,7 +622,7 @@ struct se_lun_acl {
 }  ____cacheline_aligned;
 
 struct se_dev_entry {
-	int			def_pr_registered:1;
+	bool			def_pr_registered;
 	/* See transport_lunflags_table */
 	u32			lun_flags;
 	u32			deve_cmds;
diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
index f3ac12b..5eb8b1a 100644
--- a/include/target/target_core_fabric_ops.h
+++ b/include/target/target_core_fabric_ops.h
@@ -8,7 +8,7 @@ struct target_core_fabric_ops {
 	 * for scatterlist chaining using transport_do_task_sg_link(),
 	 * disabled by default
 	 */
-	int task_sg_chaining:1;
+	bool task_sg_chaining;
 	char *(*get_fabric_name)(void);
 	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
 	char *(*tpg_get_wwn)(struct se_portal_group *);

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

* [patch] [SCSI] target: dubious one-bit signed bitfield
@ 2011-01-15 14:04 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-01-15 14:04 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: James Bottomley, linux-kernel, linux-scsi, kernel-janitors

The signed one-bit types can be 0 or -1 which can cause a problem if
someone ever checks if (foo->lu_gp_assoc = 1).  The current code is
fine because everyone just checks zero vs non-zero.  But Sparse
complains about it so lets change it.  The warnings look like this:

include/target/target_core_base.h:228:26: error: dubious one-bit signed bitfield

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 07fdfb6..764177b 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -225,7 +225,7 @@ struct t10_alua_lu_gp {
 } ____cacheline_aligned;
 
 struct t10_alua_lu_gp_member {
-	int lu_gp_assoc:1;
+	bool lu_gp_assoc;
 	atomic_t lu_gp_mem_ref_cnt;
 	spinlock_t lu_gp_mem_lock;
 	struct t10_alua_lu_gp *lu_gp;
@@ -257,7 +257,7 @@ struct t10_alua_tg_pt_gp {
 } ____cacheline_aligned;
 
 struct t10_alua_tg_pt_gp_member {
-	int tg_pt_gp_assoc:1;
+	bool tg_pt_gp_assoc;
 	atomic_t tg_pt_gp_mem_ref_cnt;
 	spinlock_t tg_pt_gp_mem_lock;
 	struct t10_alua_tg_pt_gp *tg_pt_gp;
@@ -322,7 +322,7 @@ struct t10_pr_registration {
 	int pr_res_type;
 	int pr_res_scope;
 	/* Used for fabric initiator WWPNs using a ISID */
-	int isid_present_at_reg:1;
+	bool isid_present_at_reg;
 	u32 pr_res_mapped_lun;
 	u32 pr_aptpl_target_lun;
 	u32 pr_res_generation;
@@ -404,7 +404,7 @@ struct se_transport_task {
 	unsigned long long	t_task_lba;
 	int			t_tasks_failed;
 	int			t_tasks_fua;
-	int			t_tasks_bidi:1;
+	bool			t_tasks_bidi;
 	u32			t_task_cdbs;
 	u32			t_tasks_check;
 	u32			t_tasks_no;
@@ -456,7 +456,7 @@ struct se_task {
 	u8		task_flags;
 	int		task_error_status;
 	int		task_state_flags;
-	int		task_padded_sg:1;
+	bool		task_padded_sg;
 	unsigned long long	task_lba;
 	u32		task_no;
 	u32		task_sectors;
@@ -569,7 +569,7 @@ struct se_ua {
 struct se_node_acl {
 	char			initiatorname[TRANSPORT_IQN_LEN];
 	/* Used to signal demo mode created ACL, disabled by default */
-	int			dynamic_node_acl:1;
+	bool			dynamic_node_acl;
 	u32			queue_depth;
 	u32			acl_index;
 	u64			num_cmds;
@@ -622,7 +622,7 @@ struct se_lun_acl {
 }  ____cacheline_aligned;
 
 struct se_dev_entry {
-	int			def_pr_registered:1;
+	bool			def_pr_registered;
 	/* See transport_lunflags_table */
 	u32			lun_flags;
 	u32			deve_cmds;
diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
index f3ac12b..5eb8b1a 100644
--- a/include/target/target_core_fabric_ops.h
+++ b/include/target/target_core_fabric_ops.h
@@ -8,7 +8,7 @@ struct target_core_fabric_ops {
 	 * for scatterlist chaining using transport_do_task_sg_link(),
 	 * disabled by default
 	 */
-	int task_sg_chaining:1;
+	bool task_sg_chaining;
 	char *(*get_fabric_name)(void);
 	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
 	char *(*tpg_get_wwn)(struct se_portal_group *);

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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
  2011-01-15 14:04 ` Dan Carpenter
@ 2011-01-15 16:36   ` walter harms
  -1 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2011-01-15 16:36 UTC (permalink / raw)
  To: Dan Carpenter, Nicholas A. Bellinger, James Bottomley,
	linux-kernel, linux-scsi, kernel-janitors



Am 15.01.2011 15:04, schrieb Dan Carpenter:
> The signed one-bit types can be 0 or -1 which can cause a problem if
> someone ever checks if (foo->lu_gp_assoc == 1).  The current code is
> fine because everyone just checks zero vs non-zero.  But Sparse
> complains about it so lets change it.  The warnings look like this:
> 

Your code looks ok,
but to avoid that kind of errors it may be better to use int here.

re,
 wh



> include/target/target_core_base.h:228:26: error: dubious one-bit signed bitfield
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index 07fdfb6..764177b 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -225,7 +225,7 @@ struct t10_alua_lu_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_lu_gp_member {
> -	int lu_gp_assoc:1;
> +	bool lu_gp_assoc;
>  	atomic_t lu_gp_mem_ref_cnt;
>  	spinlock_t lu_gp_mem_lock;
>  	struct t10_alua_lu_gp *lu_gp;
> @@ -257,7 +257,7 @@ struct t10_alua_tg_pt_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_tg_pt_gp_member {
> -	int tg_pt_gp_assoc:1;
> +	bool tg_pt_gp_assoc;
>  	atomic_t tg_pt_gp_mem_ref_cnt;
>  	spinlock_t tg_pt_gp_mem_lock;
>  	struct t10_alua_tg_pt_gp *tg_pt_gp;
> @@ -322,7 +322,7 @@ struct t10_pr_registration {
>  	int pr_res_type;
>  	int pr_res_scope;
>  	/* Used for fabric initiator WWPNs using a ISID */
> -	int isid_present_at_reg:1;
> +	bool isid_present_at_reg;
>  	u32 pr_res_mapped_lun;
>  	u32 pr_aptpl_target_lun;
>  	u32 pr_res_generation;
> @@ -404,7 +404,7 @@ struct se_transport_task {
>  	unsigned long long	t_task_lba;
>  	int			t_tasks_failed;
>  	int			t_tasks_fua;
> -	int			t_tasks_bidi:1;
> +	bool			t_tasks_bidi;
>  	u32			t_task_cdbs;
>  	u32			t_tasks_check;
>  	u32			t_tasks_no;
> @@ -456,7 +456,7 @@ struct se_task {
>  	u8		task_flags;
>  	int		task_error_status;
>  	int		task_state_flags;
> -	int		task_padded_sg:1;
> +	bool		task_padded_sg;
>  	unsigned long long	task_lba;
>  	u32		task_no;
>  	u32		task_sectors;
> @@ -569,7 +569,7 @@ struct se_ua {
>  struct se_node_acl {
>  	char			initiatorname[TRANSPORT_IQN_LEN];
>  	/* Used to signal demo mode created ACL, disabled by default */
> -	int			dynamic_node_acl:1;
> +	bool			dynamic_node_acl;
>  	u32			queue_depth;
>  	u32			acl_index;
>  	u64			num_cmds;
> @@ -622,7 +622,7 @@ struct se_lun_acl {
>  }  ____cacheline_aligned;
>  
>  struct se_dev_entry {
> -	int			def_pr_registered:1;
> +	bool			def_pr_registered;
>  	/* See transport_lunflags_table */
>  	u32			lun_flags;
>  	u32			deve_cmds;
> diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
> index f3ac12b..5eb8b1a 100644
> --- a/include/target/target_core_fabric_ops.h
> +++ b/include/target/target_core_fabric_ops.h
> @@ -8,7 +8,7 @@ struct target_core_fabric_ops {
>  	 * for scatterlist chaining using transport_do_task_sg_link(),
>  	 * disabled by default
>  	 */
> -	int task_sg_chaining:1;
> +	bool task_sg_chaining;
>  	char *(*get_fabric_name)(void);
>  	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
>  	char *(*tpg_get_wwn)(struct se_portal_group *);
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
@ 2011-01-15 16:36   ` walter harms
  0 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2011-01-15 16:36 UTC (permalink / raw)
  To: Dan Carpenter, Nicholas A. Bellinger, James Bottomley,
	linux-kernel, linux-scsi, kernel-janitors



Am 15.01.2011 15:04, schrieb Dan Carpenter:
> The signed one-bit types can be 0 or -1 which can cause a problem if
> someone ever checks if (foo->lu_gp_assoc = 1).  The current code is
> fine because everyone just checks zero vs non-zero.  But Sparse
> complains about it so lets change it.  The warnings look like this:
> 

Your code looks ok,
but to avoid that kind of errors it may be better to use int here.

re,
 wh



> include/target/target_core_base.h:228:26: error: dubious one-bit signed bitfield
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index 07fdfb6..764177b 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -225,7 +225,7 @@ struct t10_alua_lu_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_lu_gp_member {
> -	int lu_gp_assoc:1;
> +	bool lu_gp_assoc;
>  	atomic_t lu_gp_mem_ref_cnt;
>  	spinlock_t lu_gp_mem_lock;
>  	struct t10_alua_lu_gp *lu_gp;
> @@ -257,7 +257,7 @@ struct t10_alua_tg_pt_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_tg_pt_gp_member {
> -	int tg_pt_gp_assoc:1;
> +	bool tg_pt_gp_assoc;
>  	atomic_t tg_pt_gp_mem_ref_cnt;
>  	spinlock_t tg_pt_gp_mem_lock;
>  	struct t10_alua_tg_pt_gp *tg_pt_gp;
> @@ -322,7 +322,7 @@ struct t10_pr_registration {
>  	int pr_res_type;
>  	int pr_res_scope;
>  	/* Used for fabric initiator WWPNs using a ISID */
> -	int isid_present_at_reg:1;
> +	bool isid_present_at_reg;
>  	u32 pr_res_mapped_lun;
>  	u32 pr_aptpl_target_lun;
>  	u32 pr_res_generation;
> @@ -404,7 +404,7 @@ struct se_transport_task {
>  	unsigned long long	t_task_lba;
>  	int			t_tasks_failed;
>  	int			t_tasks_fua;
> -	int			t_tasks_bidi:1;
> +	bool			t_tasks_bidi;
>  	u32			t_task_cdbs;
>  	u32			t_tasks_check;
>  	u32			t_tasks_no;
> @@ -456,7 +456,7 @@ struct se_task {
>  	u8		task_flags;
>  	int		task_error_status;
>  	int		task_state_flags;
> -	int		task_padded_sg:1;
> +	bool		task_padded_sg;
>  	unsigned long long	task_lba;
>  	u32		task_no;
>  	u32		task_sectors;
> @@ -569,7 +569,7 @@ struct se_ua {
>  struct se_node_acl {
>  	char			initiatorname[TRANSPORT_IQN_LEN];
>  	/* Used to signal demo mode created ACL, disabled by default */
> -	int			dynamic_node_acl:1;
> +	bool			dynamic_node_acl;
>  	u32			queue_depth;
>  	u32			acl_index;
>  	u64			num_cmds;
> @@ -622,7 +622,7 @@ struct se_lun_acl {
>  }  ____cacheline_aligned;
>  
>  struct se_dev_entry {
> -	int			def_pr_registered:1;
> +	bool			def_pr_registered;
>  	/* See transport_lunflags_table */
>  	u32			lun_flags;
>  	u32			deve_cmds;
> diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
> index f3ac12b..5eb8b1a 100644
> --- a/include/target/target_core_fabric_ops.h
> +++ b/include/target/target_core_fabric_ops.h
> @@ -8,7 +8,7 @@ struct target_core_fabric_ops {
>  	 * for scatterlist chaining using transport_do_task_sg_link(),
>  	 * disabled by default
>  	 */
> -	int task_sg_chaining:1;
> +	bool task_sg_chaining;
>  	char *(*get_fabric_name)(void);
>  	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
>  	char *(*tpg_get_wwn)(struct se_portal_group *);
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
  2011-01-15 16:36   ` walter harms
@ 2011-01-15 16:54     ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-01-15 16:54 UTC (permalink / raw)
  To: walter harms
  Cc: Nicholas A. Bellinger, James Bottomley, linux-kernel, linux-scsi,
	kernel-janitors

On Sat, Jan 15, 2011 at 05:36:11PM +0100, walter harms wrote:
> 
> 
> Am 15.01.2011 15:04, schrieb Dan Carpenter:
> > The signed one-bit types can be 0 or -1 which can cause a problem if
> > someone ever checks if (foo->lu_gp_assoc == 1).  The current code is
> > fine because everyone just checks zero vs non-zero.  But Sparse
> > complains about it so lets change it.  The warnings look like this:
> > 
> 
> Your code looks ok,
> but to avoid that kind of errors it may be better to use int here.
> 

I'm afraid I don't understand what you are saying.

regards,
dan carpenter

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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
@ 2011-01-15 16:54     ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2011-01-15 16:54 UTC (permalink / raw)
  To: walter harms
  Cc: Nicholas A. Bellinger, James Bottomley, linux-kernel, linux-scsi,
	kernel-janitors

On Sat, Jan 15, 2011 at 05:36:11PM +0100, walter harms wrote:
> 
> 
> Am 15.01.2011 15:04, schrieb Dan Carpenter:
> > The signed one-bit types can be 0 or -1 which can cause a problem if
> > someone ever checks if (foo->lu_gp_assoc = 1).  The current code is
> > fine because everyone just checks zero vs non-zero.  But Sparse
> > complains about it so lets change it.  The warnings look like this:
> > 
> 
> Your code looks ok,
> but to avoid that kind of errors it may be better to use int here.
> 

I'm afraid I don't understand what you are saying.

regards,
dan carpenter

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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
  2011-01-15 14:04 ` Dan Carpenter
@ 2011-01-15 20:53   ` Nicholas A. Bellinger
  -1 siblings, 0 replies; 10+ messages in thread
From: Nicholas A. Bellinger @ 2011-01-15 20:53 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: James Bottomley, linux-kernel, linux-scsi, kernel-janitors

On Sat, 2011-01-15 at 17:04 +0300, Dan Carpenter wrote:
> The signed one-bit types can be 0 or -1 which can cause a problem if
> someone ever checks if (foo->lu_gp_assoc == 1).  The current code is
> fine because everyone just checks zero vs non-zero.  But Sparse
> complains about it so lets change it.  The warnings look like this:
> 
> include/target/target_core_base.h:228:26: error: dubious one-bit signed bitfield
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Looks reasonable to me..  Committed as daf0bd7aa57e in
lio-core-2.6.git/linus-38-rc1 and cherry picked into
scsi-post-merge-2.6.git/for-jejb.

Thanks Dan!

--nab

> 
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index 07fdfb6..764177b 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -225,7 +225,7 @@ struct t10_alua_lu_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_lu_gp_member {
> -	int lu_gp_assoc:1;
> +	bool lu_gp_assoc;
>  	atomic_t lu_gp_mem_ref_cnt;
>  	spinlock_t lu_gp_mem_lock;
>  	struct t10_alua_lu_gp *lu_gp;
> @@ -257,7 +257,7 @@ struct t10_alua_tg_pt_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_tg_pt_gp_member {
> -	int tg_pt_gp_assoc:1;
> +	bool tg_pt_gp_assoc;
>  	atomic_t tg_pt_gp_mem_ref_cnt;
>  	spinlock_t tg_pt_gp_mem_lock;
>  	struct t10_alua_tg_pt_gp *tg_pt_gp;
> @@ -322,7 +322,7 @@ struct t10_pr_registration {
>  	int pr_res_type;
>  	int pr_res_scope;
>  	/* Used for fabric initiator WWPNs using a ISID */
> -	int isid_present_at_reg:1;
> +	bool isid_present_at_reg;
>  	u32 pr_res_mapped_lun;
>  	u32 pr_aptpl_target_lun;
>  	u32 pr_res_generation;
> @@ -404,7 +404,7 @@ struct se_transport_task {
>  	unsigned long long	t_task_lba;
>  	int			t_tasks_failed;
>  	int			t_tasks_fua;
> -	int			t_tasks_bidi:1;
> +	bool			t_tasks_bidi;
>  	u32			t_task_cdbs;
>  	u32			t_tasks_check;
>  	u32			t_tasks_no;
> @@ -456,7 +456,7 @@ struct se_task {
>  	u8		task_flags;
>  	int		task_error_status;
>  	int		task_state_flags;
> -	int		task_padded_sg:1;
> +	bool		task_padded_sg;
>  	unsigned long long	task_lba;
>  	u32		task_no;
>  	u32		task_sectors;
> @@ -569,7 +569,7 @@ struct se_ua {
>  struct se_node_acl {
>  	char			initiatorname[TRANSPORT_IQN_LEN];
>  	/* Used to signal demo mode created ACL, disabled by default */
> -	int			dynamic_node_acl:1;
> +	bool			dynamic_node_acl;
>  	u32			queue_depth;
>  	u32			acl_index;
>  	u64			num_cmds;
> @@ -622,7 +622,7 @@ struct se_lun_acl {
>  }  ____cacheline_aligned;
>  
>  struct se_dev_entry {
> -	int			def_pr_registered:1;
> +	bool			def_pr_registered;
>  	/* See transport_lunflags_table */
>  	u32			lun_flags;
>  	u32			deve_cmds;
> diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
> index f3ac12b..5eb8b1a 100644
> --- a/include/target/target_core_fabric_ops.h
> +++ b/include/target/target_core_fabric_ops.h
> @@ -8,7 +8,7 @@ struct target_core_fabric_ops {
>  	 * for scatterlist chaining using transport_do_task_sg_link(),
>  	 * disabled by default
>  	 */
> -	int task_sg_chaining:1;
> +	bool task_sg_chaining;
>  	char *(*get_fabric_name)(void);
>  	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
>  	char *(*tpg_get_wwn)(struct se_portal_group *);


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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
@ 2011-01-15 20:53   ` Nicholas A. Bellinger
  0 siblings, 0 replies; 10+ messages in thread
From: Nicholas A. Bellinger @ 2011-01-15 20:53 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: James Bottomley, linux-kernel, linux-scsi, kernel-janitors

On Sat, 2011-01-15 at 17:04 +0300, Dan Carpenter wrote:
> The signed one-bit types can be 0 or -1 which can cause a problem if
> someone ever checks if (foo->lu_gp_assoc = 1).  The current code is
> fine because everyone just checks zero vs non-zero.  But Sparse
> complains about it so lets change it.  The warnings look like this:
> 
> include/target/target_core_base.h:228:26: error: dubious one-bit signed bitfield
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Looks reasonable to me..  Committed as daf0bd7aa57e in
lio-core-2.6.git/linus-38-rc1 and cherry picked into
scsi-post-merge-2.6.git/for-jejb.

Thanks Dan!

--nab

> 
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index 07fdfb6..764177b 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -225,7 +225,7 @@ struct t10_alua_lu_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_lu_gp_member {
> -	int lu_gp_assoc:1;
> +	bool lu_gp_assoc;
>  	atomic_t lu_gp_mem_ref_cnt;
>  	spinlock_t lu_gp_mem_lock;
>  	struct t10_alua_lu_gp *lu_gp;
> @@ -257,7 +257,7 @@ struct t10_alua_tg_pt_gp {
>  } ____cacheline_aligned;
>  
>  struct t10_alua_tg_pt_gp_member {
> -	int tg_pt_gp_assoc:1;
> +	bool tg_pt_gp_assoc;
>  	atomic_t tg_pt_gp_mem_ref_cnt;
>  	spinlock_t tg_pt_gp_mem_lock;
>  	struct t10_alua_tg_pt_gp *tg_pt_gp;
> @@ -322,7 +322,7 @@ struct t10_pr_registration {
>  	int pr_res_type;
>  	int pr_res_scope;
>  	/* Used for fabric initiator WWPNs using a ISID */
> -	int isid_present_at_reg:1;
> +	bool isid_present_at_reg;
>  	u32 pr_res_mapped_lun;
>  	u32 pr_aptpl_target_lun;
>  	u32 pr_res_generation;
> @@ -404,7 +404,7 @@ struct se_transport_task {
>  	unsigned long long	t_task_lba;
>  	int			t_tasks_failed;
>  	int			t_tasks_fua;
> -	int			t_tasks_bidi:1;
> +	bool			t_tasks_bidi;
>  	u32			t_task_cdbs;
>  	u32			t_tasks_check;
>  	u32			t_tasks_no;
> @@ -456,7 +456,7 @@ struct se_task {
>  	u8		task_flags;
>  	int		task_error_status;
>  	int		task_state_flags;
> -	int		task_padded_sg:1;
> +	bool		task_padded_sg;
>  	unsigned long long	task_lba;
>  	u32		task_no;
>  	u32		task_sectors;
> @@ -569,7 +569,7 @@ struct se_ua {
>  struct se_node_acl {
>  	char			initiatorname[TRANSPORT_IQN_LEN];
>  	/* Used to signal demo mode created ACL, disabled by default */
> -	int			dynamic_node_acl:1;
> +	bool			dynamic_node_acl;
>  	u32			queue_depth;
>  	u32			acl_index;
>  	u64			num_cmds;
> @@ -622,7 +622,7 @@ struct se_lun_acl {
>  }  ____cacheline_aligned;
>  
>  struct se_dev_entry {
> -	int			def_pr_registered:1;
> +	bool			def_pr_registered;
>  	/* See transport_lunflags_table */
>  	u32			lun_flags;
>  	u32			deve_cmds;
> diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
> index f3ac12b..5eb8b1a 100644
> --- a/include/target/target_core_fabric_ops.h
> +++ b/include/target/target_core_fabric_ops.h
> @@ -8,7 +8,7 @@ struct target_core_fabric_ops {
>  	 * for scatterlist chaining using transport_do_task_sg_link(),
>  	 * disabled by default
>  	 */
> -	int task_sg_chaining:1;
> +	bool task_sg_chaining;
>  	char *(*get_fabric_name)(void);
>  	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
>  	char *(*tpg_get_wwn)(struct se_portal_group *);


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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
  2011-01-15 16:54     ` Dan Carpenter
@ 2011-01-17  8:08       ` walter harms
  -1 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2011-01-17  8:08 UTC (permalink / raw)
  To: Dan Carpenter, Nicholas A. Bellinger, James Bottomley,
	linux-kernel, linux-scsi, kernel-janitors



Am 15.01.2011 17:54, schrieb Dan Carpenter:
> On Sat, Jan 15, 2011 at 05:36:11PM +0100, walter harms wrote:
>>
>>
>> Am 15.01.2011 15:04, schrieb Dan Carpenter:
>>> The signed one-bit types can be 0 or -1 which can cause a problem if
>>> someone ever checks if (foo->lu_gp_assoc == 1).  The current code is
>>> fine because everyone just checks zero vs non-zero.  But Sparse
>>> complains about it so lets change it.  The warnings look like this:
>>>
>>
>> Your code looks ok,
>> but to avoid that kind of errors it may be better to use int here.
>>
> 
> I'm afraid I don't understand what you are saying.
> 

IMHO, it is better to just drop the bitfield. Most people expect int as return.

re,
 wh

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

* Re: [patch] [SCSI] target: dubious one-bit signed bitfield
@ 2011-01-17  8:08       ` walter harms
  0 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2011-01-17  8:08 UTC (permalink / raw)
  To: Dan Carpenter, Nicholas A. Bellinger, James Bottomley,
	linux-kernel, linux-scsi, kernel-janitors



Am 15.01.2011 17:54, schrieb Dan Carpenter:
> On Sat, Jan 15, 2011 at 05:36:11PM +0100, walter harms wrote:
>>
>>
>> Am 15.01.2011 15:04, schrieb Dan Carpenter:
>>> The signed one-bit types can be 0 or -1 which can cause a problem if
>>> someone ever checks if (foo->lu_gp_assoc = 1).  The current code is
>>> fine because everyone just checks zero vs non-zero.  But Sparse
>>> complains about it so lets change it.  The warnings look like this:
>>>
>>
>> Your code looks ok,
>> but to avoid that kind of errors it may be better to use int here.
>>
> 
> I'm afraid I don't understand what you are saying.
> 

IMHO, it is better to just drop the bitfield. Most people expect int as return.

re,
 wh

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

end of thread, other threads:[~2011-01-17  8:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-15 14:04 [patch] [SCSI] target: dubious one-bit signed bitfield Dan Carpenter
2011-01-15 14:04 ` Dan Carpenter
2011-01-15 16:36 ` walter harms
2011-01-15 16:36   ` walter harms
2011-01-15 16:54   ` Dan Carpenter
2011-01-15 16:54     ` Dan Carpenter
2011-01-17  8:08     ` walter harms
2011-01-17  8:08       ` walter harms
2011-01-15 20:53 ` Nicholas A. Bellinger
2011-01-15 20:53   ` Nicholas A. Bellinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.