Skip to content

Commit 79f9abd

Browse files
Benjamin-Blockmartinkpetersen
authored andcommitted
scsi: zfcp: Make the type for accessing request hashtable buckets size_t
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>
1 parent 2702812 commit 79f9abd

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

drivers/s390/scsi/zfcp_reqlist.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
* Data structure and helper functions for tracking pending FSF
66
* requests.
77
*
8-
* Copyright IBM Corp. 2009, 2016
8+
* Copyright IBM Corp. 2009, 2023
99
*/
1010

1111
#ifndef ZFCP_REQLIST_H
1212
#define ZFCP_REQLIST_H
1313

14+
#include <linux/types.h>
15+
1416
/* number of hash buckets */
15-
#define ZFCP_REQ_LIST_BUCKETS 128
17+
#define ZFCP_REQ_LIST_BUCKETS 128u
1618

1719
/**
1820
* struct zfcp_reqlist - Container for request list (reqlist)
@@ -24,7 +26,7 @@ struct zfcp_reqlist {
2426
struct list_head buckets[ZFCP_REQ_LIST_BUCKETS];
2527
};
2628

27-
static inline int zfcp_reqlist_hash(unsigned long req_id)
29+
static inline size_t zfcp_reqlist_hash(unsigned long req_id)
2830
{
2931
return req_id % ZFCP_REQ_LIST_BUCKETS;
3032
}
@@ -37,7 +39,7 @@ static inline int zfcp_reqlist_hash(unsigned long req_id)
3739
*/
3840
static inline struct zfcp_reqlist *zfcp_reqlist_alloc(void)
3941
{
40-
unsigned int i;
42+
size_t i;
4143
struct zfcp_reqlist *rl;
4244

4345
rl = kzalloc(sizeof(struct zfcp_reqlist), GFP_KERNEL);
@@ -60,7 +62,7 @@ static inline struct zfcp_reqlist *zfcp_reqlist_alloc(void)
6062
*/
6163
static inline int zfcp_reqlist_isempty(struct zfcp_reqlist *rl)
6264
{
63-
unsigned int i;
65+
size_t i;
6466

6567
for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++)
6668
if (!list_empty(&rl->buckets[i]))
@@ -84,7 +86,7 @@ static inline struct zfcp_fsf_req *
8486
_zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id)
8587
{
8688
struct zfcp_fsf_req *req;
87-
unsigned int i;
89+
size_t i;
8890

8991
i = zfcp_reqlist_hash(req_id);
9092
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)
154156
static inline void zfcp_reqlist_add(struct zfcp_reqlist *rl,
155157
struct zfcp_fsf_req *req)
156158
{
157-
unsigned int i;
159+
size_t i;
158160
unsigned long flags;
159161

160162
i = zfcp_reqlist_hash(req->req_id);
@@ -172,7 +174,7 @@ static inline void zfcp_reqlist_add(struct zfcp_reqlist *rl,
172174
static inline void zfcp_reqlist_move(struct zfcp_reqlist *rl,
173175
struct list_head *list)
174176
{
175-
unsigned int i;
177+
size_t i;
176178
unsigned long flags;
177179

178180
spin_lock_irqsave(&rl->lock, flags);
@@ -200,7 +202,7 @@ zfcp_reqlist_apply_for_all(struct zfcp_reqlist *rl,
200202
{
201203
struct zfcp_fsf_req *req;
202204
unsigned long flags;
203-
unsigned int i;
205+
size_t i;
204206

205207
spin_lock_irqsave(&rl->lock, flags);
206208
for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++)

0 commit comments

Comments
 (0)