kernel-wide: replace USHORT_MAX, SHORT_MAX and SHORT_MIN with USHRT_MAX, SHRT_MAX...
authorAlexey Dobriyan <adobriyan@gmail.com>
Mon, 24 May 2010 21:33:03 +0000 (14:33 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 25 May 2010 15:07:02 +0000 (08:07 -0700)
- 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>
21 files changed:
drivers/dma/timb_dma.c
drivers/scsi/fcoe/fcoe.c
drivers/scsi/mpt2sas/mpt2sas_base.c
drivers/scsi/mpt2sas/mpt2sas_config.c
drivers/vhost/vhost.c
fs/nfs/super.c
fs/nfsd/nfsctl.c
fs/ocfs2/blockcheck.c
include/linux/kernel.h
include/linux/sched.h
include/net/ip.h
include/net/ipv6.h
ipc/msg.c
ipc/util.c
lib/vsprintf.c
net/9p/protocol.c
net/dccp/options.c
net/ipv4/udp.c
net/mac80211/sta_info.c
net/sunrpc/rpcb_clnt.c
security/keys/keyring.c

index 0172fa3c7a2b176ffebb2c551354a448c2fe5fa6..a1bf77c1993f32a0db84c2338270af6fff71d027 100644 (file)
@@ -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;
        }
index 9276121db1efc15ffe7dc9539f83813a088e9356..44a07593de56020b444ab64c84074b512d07aef9 100644 (file)
@@ -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,
index b830d61684ddb35fafb13401c106881b1070bb46..0ec1ed389c209b1e8273b0f4b6cdf97fc599a144 100644 (file)
@@ -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;
index e762dd3e2fcb8d04403470d0867cd24a84fd9a72..c65442982d7bbf1640c450f81d1fd25150bae6db 100644 (file)
@@ -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;
 }
index 750effe0f98b61f7134b69d7b14a85a54723cc45..c6fb8e968f219c504a90bbbca9e8e56e5af1fe5a 100644 (file)
@@ -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;
index 2f8b1157daa2cf279d4e5562300e250c3bec6c9e..04214fc5c30457ea290a2a15e0f87a5f184aea65 100644 (file)
@@ -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;
index bc3194ea01f531aac10b52d59a363f1f8369ac0b..508941c23af7fa425864eed3d3a173cd8a4a4474 100644 (file)
@@ -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);
index b7428c5d0d3b54f9eceac8460c73e4a098a45a67..ec6d123395932b69b6a67ba0b5256be02b811c6f 100644 (file)
@@ -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);
index cc5e3ffe9fcea9fe0ebfcdda855cf00754e53b45..a2e7c32e17e75a73924f05abe1ac9a289fe71b82 100644 (file)
@@ -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)
index 415b8f8a3f457118e2cdae9c00efb4130454f0e2..c0151ffd35419652b5c70f16c27978a62bea0b32 100644 (file)
@@ -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;
 
index 63548f0a44b17e933fa37cbe8283fdb93bbb179a..452f229c380aea77f0adc5e018ef2972d7fcd368 100644 (file)
@@ -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
index eba5cc00325aff321d81366b3e47c2895c265a9c..2600b69757b8c63d6ab8c570b9f0e26f195468c4 100644 (file)
@@ -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 {
index 9547cb7ac3135b9ba8964d13018f5ab6340552c9..747b65507a91c3d7a03022f17797e742a6ee53e0 100644 (file)
--- a/ipc/msg.c
+++ b/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;
index 79ce84e890f72b153ca4f77ee7abeec3a6aed496..69a0cc13d9669847cce05fd67fc2203ffdeacb9e 100644 (file)
@@ -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;
        }
index 46d34b0b74a873290b0cd9fcfff6c19561c91de4..20c95121d8a10b12edbe694dec67f92f8b4a4bcd 100644 (file)
@@ -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);
 
index 77d3aab4036b2a22e4d3831b7f0b3e21093b703b..149f82160130684701118255d2ec73f31667c72d 100644 (file)
@@ -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);
index 1b08cae9c65ba21fb1a28c255b810e868acc044a..07395f861d35aa819e154ebc66114472687e7a6a 100644 (file)
@@ -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,
index 9de6a698f91d6ed861d8dd42c803a49222db7105..baeec29fe0f1f6797967fbb08089d647f308773c 100644 (file)
@@ -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;
index 730197591ab5135e307317d7c9d8e358dae6bceb..ba9360a475b0c15f657017f5ca5b93997a70dd49 100644 (file)
@@ -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",
index 121105355f60e4a90dcb9906e878ea255499358d..dac219a56ae1a7dcf8df9ddff9a128b6caa89dac 100644 (file)
@@ -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;
index ef03a82a01352fe942694678735ad79c0b6654ec..d37f713e73ce7ef7937ef8bfe23a96960202c187 100644 (file)
@@ -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;