scsi: zfcp: Make the type for accessing request hashtable buckets size_t
authorBenjamin Block <bblock@linux.ibm.com>
Tue, 21 Feb 2023 17:55:58 +0000 (18:55 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 22 Feb 2023 03:00:51 +0000 (22:00 -0500)
The appropriate type for array indices is 'size_t' and the current
implementation in 'zfcp_reqlist.h' mixes 'int' and 'unsigned int' in
different places to access the hashtable buckets of our internal request
hash table.

To prevent any confusion, change all places to 'size_t'.

Link: https://lore.kernel.org/r/64afe93f6263c6b07815937826cd7d5fc4f1a674.1677000450.git.bblock@linux.ibm.com
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/s390/scsi/zfcp_reqlist.h

index 9b8ff24..f4bac61 100644 (file)
@@ -5,14 +5,16 @@
  * Data structure and helper functions for tracking pending FSF
  * requests.
  *
- * Copyright IBM Corp. 2009, 2016
+ * Copyright IBM Corp. 2009, 2023
  */
 
 #ifndef ZFCP_REQLIST_H
 #define ZFCP_REQLIST_H
 
+#include <linux/types.h>
+
 /* number of hash buckets */
-#define ZFCP_REQ_LIST_BUCKETS 128
+#define ZFCP_REQ_LIST_BUCKETS 128u
 
 /**
  * struct zfcp_reqlist - Container for request list (reqlist)
@@ -24,7 +26,7 @@ struct zfcp_reqlist {
        struct list_head buckets[ZFCP_REQ_LIST_BUCKETS];
 };
 
-static inline int zfcp_reqlist_hash(unsigned long req_id)
+static inline size_t zfcp_reqlist_hash(unsigned long req_id)
 {
        return req_id % ZFCP_REQ_LIST_BUCKETS;
 }
@@ -37,7 +39,7 @@ static inline int zfcp_reqlist_hash(unsigned long req_id)
  */
 static inline struct zfcp_reqlist *zfcp_reqlist_alloc(void)
 {
-       unsigned int i;
+       size_t i;
        struct zfcp_reqlist *rl;
 
        rl = kzalloc(sizeof(struct zfcp_reqlist), GFP_KERNEL);
@@ -60,7 +62,7 @@ static inline struct zfcp_reqlist *zfcp_reqlist_alloc(void)
  */
 static inline int zfcp_reqlist_isempty(struct zfcp_reqlist *rl)
 {
-       unsigned int i;
+       size_t i;
 
        for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++)
                if (!list_empty(&rl->buckets[i]))
@@ -84,7 +86,7 @@ static inline struct zfcp_fsf_req *
 _zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id)
 {
        struct zfcp_fsf_req *req;
-       unsigned int i;
+       size_t i;
 
        i = zfcp_reqlist_hash(req_id);
        list_for_each_entry(req, &rl->buckets[i], list)
@@ -154,7 +156,7 @@ zfcp_reqlist_find_rm(struct zfcp_reqlist *rl, unsigned long req_id)
 static inline void zfcp_reqlist_add(struct zfcp_reqlist *rl,
                                    struct zfcp_fsf_req *req)
 {
-       unsigned int i;
+       size_t i;
        unsigned long flags;
 
        i = zfcp_reqlist_hash(req->req_id);
@@ -172,7 +174,7 @@ static inline void zfcp_reqlist_add(struct zfcp_reqlist *rl,
 static inline void zfcp_reqlist_move(struct zfcp_reqlist *rl,
                                     struct list_head *list)
 {
-       unsigned int i;
+       size_t i;
        unsigned long flags;
 
        spin_lock_irqsave(&rl->lock, flags);
@@ -200,7 +202,7 @@ zfcp_reqlist_apply_for_all(struct zfcp_reqlist *rl,
 {
        struct zfcp_fsf_req *req;
        unsigned long flags;
-       unsigned int i;
+       size_t i;
 
        spin_lock_irqsave(&rl->lock, flags);
        for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++)