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>
This commit is contained in:
parent
940370fc86
commit
4be929be34
|
@ -188,7 +188,7 @@ static void __td_unmap_descs(struct timb_dma_desc *td_desc, bool single)
|
|||
static int td_fill_desc(struct timb_dma_chan *td_chan, u8 *dma_desc,
|
||||
struct scatterlist *sg, bool last)
|
||||
{
|
||||
if (sg_dma_len(sg) > USHORT_MAX) {
|
||||
if (sg_dma_len(sg) > USHRT_MAX) {
|
||||
dev_err(chan2dev(&td_chan->chan), "Too big sg element\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
@ -688,7 +688,7 @@ static int fcoe_shost_config(struct fc_lport *lport, struct device *dev)
|
|||
}
|
||||
|
||||
if (!lport->vport)
|
||||
fc_host_max_npiv_vports(lport->host) = USHORT_MAX;
|
||||
fc_host_max_npiv_vports(lport->host) = USHRT_MAX;
|
||||
|
||||
snprintf(fc_host_symbolic_name(lport->host), FC_SYMBOLIC_NAME_SIZE,
|
||||
"%s v%s over %s", FCOE_NAME, FCOE_VERSION,
|
||||
|
|
|
@ -3757,7 +3757,7 @@ _base_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase)
|
|||
if (ioc->config_cmds.status & MPT2_CMD_PENDING) {
|
||||
ioc->config_cmds.status |= MPT2_CMD_RESET;
|
||||
mpt2sas_base_free_smid(ioc, ioc->config_cmds.smid);
|
||||
ioc->config_cmds.smid = USHORT_MAX;
|
||||
ioc->config_cmds.smid = USHRT_MAX;
|
||||
complete(&ioc->config_cmds.done);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -258,7 +258,7 @@ mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
|
|||
#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
|
||||
_config_display_some_debug(ioc, smid, "config_done", mpi_reply);
|
||||
#endif
|
||||
ioc->config_cmds.smid = USHORT_MAX;
|
||||
ioc->config_cmds.smid = USHRT_MAX;
|
||||
complete(&ioc->config_cmds.done);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -806,7 +806,7 @@ static unsigned get_indirect(struct vhost_dev *dev, struct vhost_virtqueue *vq,
|
|||
count = indirect->len / sizeof desc;
|
||||
/* Buffers are chained via a 16 bit next field, so
|
||||
* we can have at most 2^16 of these. */
|
||||
if (count > USHORT_MAX + 1) {
|
||||
if (count > USHRT_MAX + 1) {
|
||||
vq_err(vq, "Indirect buffer length too big: %d\n",
|
||||
indirect->len);
|
||||
return -E2BIG;
|
||||
|
|
|
@ -1060,7 +1060,7 @@ static int nfs_parse_mount_options(char *raw,
|
|||
goto out_nomem;
|
||||
rc = strict_strtoul(string, 10, &option);
|
||||
kfree(string);
|
||||
if (rc != 0 || option > USHORT_MAX)
|
||||
if (rc != 0 || option > USHRT_MAX)
|
||||
goto out_invalid_value;
|
||||
mnt->nfs_server.port = option;
|
||||
break;
|
||||
|
@ -1181,7 +1181,7 @@ static int nfs_parse_mount_options(char *raw,
|
|||
goto out_nomem;
|
||||
rc = strict_strtoul(string, 10, &option);
|
||||
kfree(string);
|
||||
if (rc != 0 || option > USHORT_MAX)
|
||||
if (rc != 0 || option > USHRT_MAX)
|
||||
goto out_invalid_value;
|
||||
mnt->mount_server.port = option;
|
||||
break;
|
||||
|
|
|
@ -998,7 +998,7 @@ static ssize_t __write_ports_addxprt(char *buf)
|
|||
if (sscanf(buf, "%15s %4u", transport, &port) != 2)
|
||||
return -EINVAL;
|
||||
|
||||
if (port < 1 || port > USHORT_MAX)
|
||||
if (port < 1 || port > USHRT_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
err = nfsd_create_serv();
|
||||
|
@ -1040,7 +1040,7 @@ static ssize_t __write_ports_delxprt(char *buf)
|
|||
if (sscanf(&buf[1], "%15s %4u", transport, &port) != 2)
|
||||
return -EINVAL;
|
||||
|
||||
if (port < 1 || port > USHORT_MAX || nfsd_serv == NULL)
|
||||
if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
xprt = svc_find_xprt(nfsd_serv, transport, AF_UNSPEC, port);
|
||||
|
|
|
@ -403,7 +403,7 @@ void ocfs2_block_check_compute(void *data, size_t blocksize,
|
|||
* No ecc'd ocfs2 structure is larger than 4K, so ecc will be no
|
||||
* larger than 16 bits.
|
||||
*/
|
||||
BUG_ON(ecc > USHORT_MAX);
|
||||
BUG_ON(ecc > USHRT_MAX);
|
||||
|
||||
bc->bc_crc32e = cpu_to_le32(crc);
|
||||
bc->bc_ecc = cpu_to_le16((u16)ecc);
|
||||
|
@ -508,7 +508,7 @@ void ocfs2_block_check_compute_bhs(struct buffer_head **bhs, int nr,
|
|||
* No ecc'd ocfs2 structure is larger than 4K, so ecc will be no
|
||||
* larger than 16 bits.
|
||||
*/
|
||||
BUG_ON(ecc > USHORT_MAX);
|
||||
BUG_ON(ecc > USHRT_MAX);
|
||||
|
||||
bc->bc_crc32e = cpu_to_le32(crc);
|
||||
bc->bc_ecc = cpu_to_le16((u16)ecc);
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
extern const char linux_banner[];
|
||||
extern const char linux_proc_banner[];
|
||||
|
||||
#define USHORT_MAX ((u16)(~0U))
|
||||
#define SHORT_MAX ((s16)(USHORT_MAX>>1))
|
||||
#define SHORT_MIN (-SHORT_MAX - 1)
|
||||
#define USHRT_MAX ((u16)(~0U))
|
||||
#define SHRT_MAX ((s16)(USHRT_MAX>>1))
|
||||
#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
|
||||
#define INT_MAX ((int)(~0U>>1))
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
#define UINT_MAX (~0U)
|
||||
|
|
|
@ -384,7 +384,7 @@ struct user_namespace;
|
|||
* 1-3 now and depends on arch. We use "5" as safe margin, here.
|
||||
*/
|
||||
#define MAPCOUNT_ELF_CORE_MARGIN (5)
|
||||
#define DEFAULT_MAX_MAP_COUNT (USHORT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
|
||||
#define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
|
||||
|
||||
extern int sysctl_max_map_count;
|
||||
|
||||
|
|
|
@ -358,11 +358,11 @@ enum ip_defrag_users {
|
|||
IP_DEFRAG_LOCAL_DELIVER,
|
||||
IP_DEFRAG_CALL_RA_CHAIN,
|
||||
IP_DEFRAG_CONNTRACK_IN,
|
||||
__IP_DEFRAG_CONNTRACK_IN_END = IP_DEFRAG_CONNTRACK_IN + USHORT_MAX,
|
||||
__IP_DEFRAG_CONNTRACK_IN_END = IP_DEFRAG_CONNTRACK_IN + USHRT_MAX,
|
||||
IP_DEFRAG_CONNTRACK_OUT,
|
||||
__IP_DEFRAG_CONNTRACK_OUT_END = IP_DEFRAG_CONNTRACK_OUT + USHORT_MAX,
|
||||
__IP_DEFRAG_CONNTRACK_OUT_END = IP_DEFRAG_CONNTRACK_OUT + USHRT_MAX,
|
||||
IP_DEFRAG_CONNTRACK_BRIDGE_IN,
|
||||
__IP_DEFRAG_CONNTRACK_BRIDGE_IN = IP_DEFRAG_CONNTRACK_BRIDGE_IN + USHORT_MAX,
|
||||
__IP_DEFRAG_CONNTRACK_BRIDGE_IN = IP_DEFRAG_CONNTRACK_BRIDGE_IN + USHRT_MAX,
|
||||
IP_DEFRAG_VS_IN,
|
||||
IP_DEFRAG_VS_OUT,
|
||||
IP_DEFRAG_VS_FWD
|
||||
|
|
|
@ -354,11 +354,11 @@ struct inet_frag_queue;
|
|||
enum ip6_defrag_users {
|
||||
IP6_DEFRAG_LOCAL_DELIVER,
|
||||
IP6_DEFRAG_CONNTRACK_IN,
|
||||
__IP6_DEFRAG_CONNTRACK_IN = IP6_DEFRAG_CONNTRACK_IN + USHORT_MAX,
|
||||
__IP6_DEFRAG_CONNTRACK_IN = IP6_DEFRAG_CONNTRACK_IN + USHRT_MAX,
|
||||
IP6_DEFRAG_CONNTRACK_OUT,
|
||||
__IP6_DEFRAG_CONNTRACK_OUT = IP6_DEFRAG_CONNTRACK_OUT + USHORT_MAX,
|
||||
__IP6_DEFRAG_CONNTRACK_OUT = IP6_DEFRAG_CONNTRACK_OUT + USHRT_MAX,
|
||||
IP6_DEFRAG_CONNTRACK_BRIDGE_IN,
|
||||
__IP6_DEFRAG_CONNTRACK_BRIDGE_IN = IP6_DEFRAG_CONNTRACK_BRIDGE_IN + USHORT_MAX,
|
||||
__IP6_DEFRAG_CONNTRACK_BRIDGE_IN = IP6_DEFRAG_CONNTRACK_BRIDGE_IN + USHRT_MAX,
|
||||
};
|
||||
|
||||
struct ip6_create_arg {
|
||||
|
|
12
ipc/msg.c
12
ipc/msg.c
|
@ -345,19 +345,19 @@ copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version)
|
|||
out.msg_rtime = in->msg_rtime;
|
||||
out.msg_ctime = in->msg_ctime;
|
||||
|
||||
if (in->msg_cbytes > USHORT_MAX)
|
||||
out.msg_cbytes = USHORT_MAX;
|
||||
if (in->msg_cbytes > USHRT_MAX)
|
||||
out.msg_cbytes = USHRT_MAX;
|
||||
else
|
||||
out.msg_cbytes = in->msg_cbytes;
|
||||
out.msg_lcbytes = in->msg_cbytes;
|
||||
|
||||
if (in->msg_qnum > USHORT_MAX)
|
||||
out.msg_qnum = USHORT_MAX;
|
||||
if (in->msg_qnum > USHRT_MAX)
|
||||
out.msg_qnum = USHRT_MAX;
|
||||
else
|
||||
out.msg_qnum = in->msg_qnum;
|
||||
|
||||
if (in->msg_qbytes > USHORT_MAX)
|
||||
out.msg_qbytes = USHORT_MAX;
|
||||
if (in->msg_qbytes > USHRT_MAX)
|
||||
out.msg_qbytes = USHRT_MAX;
|
||||
else
|
||||
out.msg_qbytes = in->msg_qbytes;
|
||||
out.msg_lqbytes = in->msg_qbytes;
|
||||
|
|
|
@ -124,8 +124,8 @@ void ipc_init_ids(struct ipc_ids *ids)
|
|||
ids->seq = 0;
|
||||
{
|
||||
int seq_limit = INT_MAX/SEQ_MULTIPLIER;
|
||||
if (seq_limit > USHORT_MAX)
|
||||
ids->seq_max = USHORT_MAX;
|
||||
if (seq_limit > USHRT_MAX)
|
||||
ids->seq_max = USHRT_MAX;
|
||||
else
|
||||
ids->seq_max = seq_limit;
|
||||
}
|
||||
|
|
|
@ -1980,7 +1980,7 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
|
|||
{
|
||||
char *s = (char *)va_arg(args, char *);
|
||||
if (field_width == -1)
|
||||
field_width = SHORT_MAX;
|
||||
field_width = SHRT_MAX;
|
||||
/* first, skip leading white space in buffer */
|
||||
str = skip_spaces(str);
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
|
|||
const char *sptr = va_arg(ap, const char *);
|
||||
int16_t len = 0;
|
||||
if (sptr)
|
||||
len = MIN(strlen(sptr), USHORT_MAX);
|
||||
len = MIN(strlen(sptr), USHRT_MAX);
|
||||
|
||||
errcode = p9pdu_writef(pdu, proto_version,
|
||||
"w", len);
|
||||
|
|
|
@ -296,7 +296,7 @@ static inline u8 dccp_ndp_len(const u64 ndp)
|
|||
{
|
||||
if (likely(ndp <= 0xFF))
|
||||
return 1;
|
||||
return likely(ndp <= USHORT_MAX) ? 2 : (ndp <= UINT_MAX ? 4 : 6);
|
||||
return likely(ndp <= USHRT_MAX) ? 2 : (ndp <= UINT_MAX ? 4 : 6);
|
||||
}
|
||||
|
||||
int dccp_insert_option(struct sock *sk, struct sk_buff *skb,
|
||||
|
|
|
@ -1686,8 +1686,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
|
|||
return -ENOPROTOOPT;
|
||||
if (val != 0 && val < 8) /* Illegal coverage: use default (8) */
|
||||
val = 8;
|
||||
else if (val > USHORT_MAX)
|
||||
val = USHORT_MAX;
|
||||
else if (val > USHRT_MAX)
|
||||
val = USHRT_MAX;
|
||||
up->pcslen = val;
|
||||
up->pcflag |= UDPLITE_SEND_CC;
|
||||
break;
|
||||
|
@ -1700,8 +1700,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
|
|||
return -ENOPROTOOPT;
|
||||
if (val != 0 && val < 8) /* Avoid silly minimal values. */
|
||||
val = 8;
|
||||
else if (val > USHORT_MAX)
|
||||
val = USHORT_MAX;
|
||||
else if (val > USHRT_MAX)
|
||||
val = USHRT_MAX;
|
||||
up->pcrlen = val;
|
||||
up->pcflag |= UDPLITE_RECV_CC;
|
||||
break;
|
||||
|
|
|
@ -259,7 +259,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
|
|||
skb_queue_head_init(&sta->tx_filtered);
|
||||
|
||||
for (i = 0; i < NUM_RX_DATA_QUEUES; i++)
|
||||
sta->last_seq_ctrl[i] = cpu_to_le16(USHORT_MAX);
|
||||
sta->last_seq_ctrl[i] = cpu_to_le16(USHRT_MAX);
|
||||
|
||||
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
|
||||
printk(KERN_DEBUG "%s: Allocated STA %pM\n",
|
||||
|
|
|
@ -783,7 +783,7 @@ static int rpcb_dec_getport(struct rpc_rqst *req, __be32 *p,
|
|||
port = ntohl(*p);
|
||||
dprintk("RPC: %5u PMAP_%s result: %lu\n", task->tk_pid,
|
||||
task->tk_msg.rpc_proc->p_name, port);
|
||||
if (unlikely(port > USHORT_MAX))
|
||||
if (unlikely(port > USHRT_MAX))
|
||||
return -EIO;
|
||||
|
||||
rpcb->r_port = port;
|
||||
|
|
|
@ -669,7 +669,7 @@ static void keyring_unlink_rcu_disposal(struct rcu_head *rcu)
|
|||
struct keyring_list *klist =
|
||||
container_of(rcu, struct keyring_list, rcu);
|
||||
|
||||
if (klist->delkey != USHORT_MAX)
|
||||
if (klist->delkey != USHRT_MAX)
|
||||
key_put(klist->keys[klist->delkey]);
|
||||
kfree(klist);
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
|
|||
max += klist->maxkeys;
|
||||
|
||||
ret = -ENFILE;
|
||||
if (max > USHORT_MAX - 1)
|
||||
if (max > USHRT_MAX - 1)
|
||||
goto error_quota;
|
||||
size = sizeof(*klist) + sizeof(struct key *) * max;
|
||||
if (size > PAGE_SIZE)
|
||||
|
@ -763,7 +763,7 @@ int __key_link_begin(struct key *keyring, const struct key_type *type,
|
|||
sizeof(struct key *) * klist->nkeys);
|
||||
nklist->delkey = klist->nkeys;
|
||||
nklist->nkeys = klist->nkeys + 1;
|
||||
klist->delkey = USHORT_MAX;
|
||||
klist->delkey = USHRT_MAX;
|
||||
} else {
|
||||
nklist->nkeys = 1;
|
||||
nklist->delkey = 0;
|
||||
|
|
Loading…
Reference in New Issue