Skip to content

Commit 4be929b

Browse files
Alexey Dobriyantorvalds
authored andcommitted
kernel-wide: replace USHORT_MAX, SHORT_MAX and SHORT_MIN with USHRT_MAX, SHRT_MAX and SHRT_MIN
- C99 knows about USHRT_MAX/SHRT_MAX/SHRT_MIN, not USHORT_MAX/SHORT_MAX/SHORT_MIN. - Make SHRT_MIN of type s16, not int, for consistency. [akpm@linux-foundation.org: fix drivers/dma/timb_dma.c] [akpm@linux-foundation.org: fix security/keys/keyring.c] Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Acked-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 940370f commit 4be929b

21 files changed

Lines changed: 41 additions & 41 deletions

File tree

‎drivers/dma/timb_dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static void __td_unmap_descs(struct timb_dma_desc *td_desc, bool single)
188188
static int td_fill_desc(struct timb_dma_chan *td_chan, u8 *dma_desc,
189189
struct scatterlist *sg, bool last)
190190
{
191-
if (sg_dma_len(sg) > USHORT_MAX) {
191+
if (sg_dma_len(sg) > USHRT_MAX) {
192192
dev_err(chan2dev(&td_chan->chan), "Too big sg element\n");
193193
return -EINVAL;
194194
}

‎drivers/scsi/fcoe/fcoe.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static int fcoe_shost_config(struct fc_lport *lport, struct device *dev)
688688
}
689689

690690
if (!lport->vport)
691-
fc_host_max_npiv_vports(lport->host) = USHORT_MAX;
691+
fc_host_max_npiv_vports(lport->host) = USHRT_MAX;
692692

693693
snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE,
694694
"%s v%s over %s", FCOE_NAME, FCOE_VERSION,

‎drivers/scsi/mpt2sas/mpt2sas_base.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3757,7 +3757,7 @@ _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
37573757
if (ioc->config_cmds.status & MPT2_CMD_PENDING) {
37583758
ioc->config_cmds.status |= MPT2_CMD_RESET;
37593759
mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid);
3760-
ioc->config_cmds.smid = USHORT_MAX;
3760+
ioc->config_cmds.smid = USHRT_MAX;
37613761
complete(&ioc->config_cmds.done);
37623762
}
37633763
break;

‎drivers/scsi/mpt2sas/mpt2sas_config.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
258258
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
259259
_config_display_some_debug(ioc, smid, "config_done", mpi_reply);
260260
#endif
261-
ioc->config_cmds.smid = USHORT_MAX;
261+
ioc->config_cmds.smid = USHRT_MAX;
262262
complete(&ioc->config_cmds.done);
263263
return 1;
264264
}

‎drivers/vhost/vhost.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
806806
count = indirect->len / sizeof desc;
807807
/* Buffers are chained via a 16 bit next field, so
808808
* we can have at most 2^16 of these. */
809-
if (count > USHORT_MAX + 1) {
809+
if (count > USHRT_MAX + 1) {
810810
vq_err(vq, "Indirect buffer length too big: %d\n",
811811
indirect->len);
812812
return -E2BIG;

‎fs/nfs/super.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@ static int nfs_parse_mount_options(char *raw,
10601060
goto out_nomem;
10611061
rc = strict_strtoul(string, 10, &option);
10621062
kfree(string);
1063-
if (rc != 0 || option > USHORT_MAX)
1063+
if (rc != 0 || option > USHRT_MAX)
10641064
goto out_invalid_value;
10651065
mnt->nfs_server.port = option;
10661066
break;
@@ -1181,7 +1181,7 @@ static int nfs_parse_mount_options(char *raw,
11811181
goto out_nomem;
11821182
rc = strict_strtoul(string, 10, &option);
11831183
kfree(string);
1184-
if (rc != 0 || option > USHORT_MAX)
1184+
if (rc != 0 || option > USHRT_MAX)
11851185
goto out_invalid_value;
11861186
mnt->mount_server.port = option;
11871187
break;

‎fs/nfsd/nfsctl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ static ssize_t __write_ports_addxprt(char *buf)
998998
if (sscanf(buf, "%15s %4u", transport, &port) != 2)
999999
return -EINVAL;
10001000

1001-
if (port < 1 || port > USHORT_MAX)
1001+
if (port < 1 || port > USHRT_MAX)
10021002
return -EINVAL;
10031003

10041004
err = nfsd_create_serv();
@@ -1040,7 +1040,7 @@ static ssize_t __write_ports_delxprt(char *buf)
10401040
if (sscanf(&buf[1], "%15s %4u", transport, &port) != 2)
10411041
return -EINVAL;
10421042

1043-
if (port < 1 || port > USHORT_MAX || nfsd_serv == NULL)
1043+
if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL)
10441044
return -EINVAL;
10451045

10461046
xprt = svc_find_xprt(nfsd_serv, transport, AF_UNSPEC, port);

‎fs/ocfs2/blockcheck.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ void ocfs2_block_check_compute(void *data, size_t blocksize,
403403
* No ecc'd ocfs2 structure is larger than 4K, so ecc will be no
404404
* larger than 16 bits.
405405
*/
406-
BUG_ON(ecc > USHORT_MAX);
406+
BUG_ON(ecc > USHRT_MAX);
407407

408408
bc->bc_crc32e = cpu_to_le32(crc);
409409
bc->bc_ecc = cpu_to_le16((u16)ecc);
@@ -508,7 +508,7 @@ void ocfs2_block_check_compute_bhs(struct buffer_head **bhs, int nr,
508508
* No ecc'd ocfs2 structure is larger than 4K, so ecc will be no
509509
* larger than 16 bits.
510510
*/
511-
BUG_ON(ecc > USHORT_MAX);
511+
BUG_ON(ecc > USHRT_MAX);
512512

513513
bc->bc_crc32e = cpu_to_le32(crc);
514514
bc->bc_ecc = cpu_to_le16((u16)ecc);

‎include/linux/kernel.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
extern const char linux_banner[];
2525
extern const char linux_proc_banner[];
2626

27-
#define USHORT_MAX ((u16)(~0U))
28-
#define SHORT_MAX ((s16)(USHORT_MAX>>1))
29-
#define SHORT_MIN (-SHORT_MAX - 1)
27+
#define USHRT_MAX ((u16)(~0U))
28+
#define SHRT_MAX ((s16)(USHRT_MAX>>1))
29+
#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
3030
#define INT_MAX ((int)(~0U>>1))
3131
#define INT_MIN (-INT_MAX - 1)
3232
#define UINT_MAX (~0U)

‎include/linux/sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ struct user_namespace;
384384
* 1-3 now and depends on arch. We use "5" as safe margin, here.
385385
*/
386386
#define MAPCOUNT_ELF_CORE_MARGIN (5)
387-
#define DEFAULT_MAX_MAP_COUNT (USHORT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
387+
#define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
388388

389389
extern int sysctl_max_map_count;
390390

0 commit comments

Comments
 (0)