staging: lustre: use min/max instead of MIN/MAX, simple cases
authorJeremiah Mahler <jmmahler@gmail.com>
Fri, 26 Dec 2014 00:04:41 +0000 (16:04 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2015 23:49:21 +0000 (15:49 -0800)
Custom MIN/MAX operations are being used which are not as robust
as the built in min/max operations which will warn about potentially
problematic type comparisons.

For the simple cases, where no type warning is produced, simply
replace MIN/MAX with min/max.

Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
drivers/staging/lustre/lnet/lnet/lib-move.c
drivers/staging/lustre/lnet/lnet/router.c
drivers/staging/lustre/lnet/selftest/conrpc.h
drivers/staging/lustre/lnet/selftest/rpc.c
drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c

index 77e9f6f9c4b3dba37e38805fcd9a1d553623b369..4fd5d94dbbff3000ccbe48c25592fe9c79a1d3c9 100644 (file)
@@ -1125,7 +1125,7 @@ kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
                        break;
                }
 
-               wrknob = MIN(MIN(kiblnd_rd_frag_size(srcrd, srcidx),
+               wrknob = min(min(kiblnd_rd_frag_size(srcrd, srcidx),
                                 kiblnd_rd_frag_size(dstrd, dstidx)), resid);
 
                sge = &tx->tx_sge[tx->tx_nwrq];
index 9188b34e694818ebc01de7f362ab494ecfbe0161..5956dbac5d047c116872843f7e7ed7514e40ac15 100644 (file)
@@ -773,7 +773,7 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
        /* Only match interfaces for additional connections
         * if I have > 1 interface */
        n_ips = (net->ksnn_ninterfaces < 2) ? 0 :
-               MIN(n_peerips, net->ksnn_ninterfaces);
+               min(n_peerips, net->ksnn_ninterfaces);
 
        for (i = 0; peer->ksnp_n_passive_ips < n_ips; i++) {
                /*            ^ yes really... */
index 768c671a15b7c7d74b87dce40f79504f5b988901..0910a18599909a61f3065d983edbf2ba890003c5 100644 (file)
@@ -1950,10 +1950,10 @@ ksocknal_connect (ksock_route_t *route)
        /* This is a retry rather than a new connection */
        route->ksnr_retry_interval *= 2;
        route->ksnr_retry_interval =
-               MAX(route->ksnr_retry_interval,
+               max(route->ksnr_retry_interval,
                    cfs_time_seconds(*ksocknal_tunables.ksnd_min_reconnectms)/1000);
        route->ksnr_retry_interval =
-               MIN(route->ksnr_retry_interval,
+               min(route->ksnr_retry_interval,
                    cfs_time_seconds(*ksocknal_tunables.ksnd_max_reconnectms)/1000);
 
        LASSERT (route->ksnr_retry_interval != 0);
index 39a41c780c261f5a18e3168a61af4e6300def90d..4182bdaaee7168369fb6fb00dd8409eaf7518e97 100644 (file)
@@ -201,9 +201,9 @@ lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset,
        do {
                LASSERT(ndiov > 0);
                LASSERT(nsiov > 0);
-               this_nob = MIN(diov->iov_len - doffset,
+               this_nob = min(diov->iov_len - doffset,
                               siov->iov_len - soffset);
-               this_nob = MIN(this_nob, nob);
+               this_nob = min(this_nob, nob);
 
                memcpy((char *)diov->iov_base + doffset,
                        (char *)siov->iov_base + soffset, this_nob);
@@ -322,9 +322,9 @@ lnet_copy_kiov2kiov(unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset,
        do {
                LASSERT(ndiov > 0);
                LASSERT(nsiov > 0);
-               this_nob = MIN(diov->kiov_len - doffset,
+               this_nob = min(diov->kiov_len - doffset,
                               siov->kiov_len - soffset);
-               this_nob = MIN(this_nob, nob);
+               this_nob = min(this_nob, nob);
 
                if (daddr == NULL)
                        daddr = ((char *)kmap(diov->kiov_page)) +
@@ -405,7 +405,7 @@ lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov, unsigned int iovoffset,
                LASSERT(nkiov > 0);
                this_nob = MIN(iov->iov_len - iovoffset,
                               kiov->kiov_len - kiovoffset);
-               this_nob = MIN(this_nob, nob);
+               this_nob = min(this_nob, nob);
 
                if (addr == NULL)
                        addr = ((char *)kmap(kiov->kiov_page)) +
@@ -476,7 +476,7 @@ lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov,
                LASSERT(niov > 0);
                this_nob = MIN(kiov->kiov_len - kiovoffset,
                               iov->iov_len - iovoffset);
-               this_nob = MIN(this_nob, nob);
+               this_nob = min(this_nob, nob);
 
                if (addr == NULL)
                        addr = ((char *)kmap(kiov->kiov_page)) +
index c667b5b767619dd7f6e4d65f333903112d115bd2..b43e1107633c75a73ddbf11e7902ba57701c2336 100644 (file)
@@ -793,7 +793,7 @@ lnet_update_ni_status_locked(void)
        LASSERT(the_lnet.ln_routing);
 
        timeout = router_ping_timeout +
-                 MAX(live_router_check_interval, dead_router_check_interval);
+                 max(live_router_check_interval, dead_router_check_interval);
 
        now = get_seconds();
        list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) {
@@ -1593,7 +1593,7 @@ lnet_router_checker (void)
                return;
 
        if (last != 0 &&
-           interval > MAX(live_router_check_interval,
+           interval > max(live_router_check_interval,
                           dead_router_check_interval))
                CNETERR("Checker(%d/%d) not called for %d seconds\n",
                        live_router_check_interval, dead_router_check_interval,
index fc1cb56cbab21971ed150dddad2d7918cde5eda2..2353889c6eacc9d5f3495e63929797dca69ca7d9 100644 (file)
@@ -54,7 +54,7 @@
 #define LST_TRANS_TIMEOUT       30
 #define LST_TRANS_MIN_TIMEOUT   3
 
-#define LST_VALIDATE_TIMEOUT(t) MIN(MAX(t, LST_TRANS_MIN_TIMEOUT), LST_TRANS_TIMEOUT)
+#define LST_VALIDATE_TIMEOUT(t) min(max(t, LST_TRANS_MIN_TIMEOUT), LST_TRANS_TIMEOUT)
 
 #define LST_PING_INTERVAL       8
 
index f753add7bfb3a49c3870e7d28c4349508c3332de..b602077c8bb51938e1a6e66fd0403b53a50600bc 100644 (file)
@@ -559,7 +559,7 @@ srpc_add_buffer(struct swi_workitem *wi)
                LASSERT(scd->scd_buf_posting > 0);
                scd->scd_buf_posting--;
                scd->scd_buf_total++;
-               scd->scd_buf_low = MAX(2, scd->scd_buf_total / 4);
+               scd->scd_buf_low = max(2, scd->scd_buf_total / 4);
        }
 
        if (rc != 0) {
@@ -1486,7 +1486,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
                if (scd->scd_buf_err == 0 && /* adding buffer is enabled */
                    scd->scd_buf_adjust == 0 &&
                    scd->scd_buf_nposted < scd->scd_buf_low) {
-                       scd->scd_buf_adjust = MAX(scd->scd_buf_total / 2,
+                       scd->scd_buf_adjust = max(scd->scd_buf_total / 2,
                                                  SFW_TEST_WI_MIN);
                        swi_schedule_workitem(&scd->scd_buf_wi);
                }
index 976c61ed49f4310164bfe64aa2384d72cc93e64d..fdc718966d21d0fa23762fd0e6bd02a78dbb3048 100644 (file)
@@ -269,5 +269,5 @@ int cfs_trace_max_debug_mb(void)
 {
        int  total_mb = (totalram_pages >> (20 - PAGE_SHIFT));
 
-       return MAX(512, (total_mb * 80)/100);
+       return max(512, (total_mb * 80)/100);
 }