]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
misc: clean up MIN/MAX in the utilities
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 1 Aug 2018 22:06:45 +0000 (17:06 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 1 Aug 2018 22:06:45 +0000 (17:06 -0500)
Get rid of the MIN/MAX macros and just use the native min/max macros
directly in the XFS code, just like we did for libxfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
16 files changed:
copy/xfs_copy.c
db/check.c
libxfs/rdwr.c
logprint/log_misc.c
logprint/log_redo.c
man/man5/xfs.5
mkfs/xfs_mkfs.c
quota/util.c
repair/attr_repair.c
repair/bmap.c
repair/btree.c
repair/dinode.c
repair/incore.c
repair/incore_ino.c
repair/prefetch.c
repair/xfs_repair.c

index 29618aec66e3cb2eb625196e15301bd6283d1300..a7b46566c3f21ceb99cd1d22cc44a692678e6ee3 100644 (file)
@@ -665,7 +665,7 @@ main(int argc, char **argv)
                }
 
                wbuf_align = d.d_mem;
-               wbuf_size = MIN(d.d_maxiosz, 1 * 1024 * 1024);
+               wbuf_size = min(d.d_maxiosz, 1 * 1024 * 1024);
                wbuf_miniosize = d.d_miniosz;
        } else  {
                /* set arbitrary I/O params, miniosize at least 1 disk block */
@@ -848,9 +848,9 @@ main(int argc, char **argv)
                                                progname, target[i].name);
                                        die_perror();
                                } else {
-                                       wbuf_align = MAX(wbuf_align, d.d_mem);
-                                       wbuf_size = MIN(d.d_maxiosz, wbuf_size);
-                                       wbuf_miniosize = MAX(d.d_miniosz,
+                                       wbuf_align = max(wbuf_align, d.d_mem);
+                                       wbuf_size = min(d.d_maxiosz, wbuf_size);
+                                       wbuf_miniosize = max(d.d_miniosz,
                                                                wbuf_miniosize);
                                }
                        }
@@ -888,7 +888,7 @@ main(int argc, char **argv)
 
        wblocks = wbuf_size / BBSIZE;
 
-       if (wbuf_init(&btree_buf, MAX(source_blocksize, wbuf_miniosize),
+       if (wbuf_init(&btree_buf, max(source_blocksize, wbuf_miniosize),
                                wbuf_align, wbuf_miniosize, 1) == NULL)  {
                do_log(_("Error initializing btree buf 1\n"));
                die_perror();
index 76c28d49347ff7dfe390cc75425378a5bf47dd73..e85afb9e7c65df087871e337eca1d94819aa1d48 100644 (file)
@@ -1853,7 +1853,7 @@ init(
        inomap = xmalloc((mp->m_sb.sb_agcount + rt) * sizeof(*inomap));
        inodata = xmalloc(mp->m_sb.sb_agcount * sizeof(*inodata));
        inodata_hash_size =
-               (int)MAX(MIN(mp->m_sb.sb_icount /
+               (int)max(min(mp->m_sb.sb_icount /
                                (INODATA_AVG_HASH_LENGTH * mp->m_sb.sb_agcount),
                             MAX_INODATA_HASH_SIZE),
                         MIN_INODATA_HASH_SIZE);
@@ -4581,7 +4581,7 @@ scanfunc_fino(
                                        goto next_buf;
 
                                 check_set_dbmap(seqno, agbno,
-                                        (xfs_extlen_t)MAX(1,
+                                        (xfs_extlen_t)max(1,
                                                 inodes_per_buf >>
                                                 mp->m_sb.sb_inopblog),
                                         DBM_INODE, DBM_INODE, seqno, bno);
index f50876b053ad2811e23b990a0ddaa4f616f54442..14a4633e9fa60d3a722d11b257b879ed74e67adf 100644 (file)
@@ -181,7 +181,7 @@ libxfs_log_clear(
         * previous cycle.
         */
        len = ((version == 2) && sunit) ? BTOBB(sunit) : 2;
-       len = MAX(len, 2);
+       len = max(len, 2);
        lsn = xlog_assign_lsn(cycle, 0);
        if (cycle == XLOG_INIT_CYCLE)
                tail_lsn = lsn;
@@ -295,7 +295,7 @@ libxfs_log_header(
        head->h_prev_block = cpu_to_be32(-1);
        head->h_num_logops = cpu_to_be32(1);
        head->h_fmt = cpu_to_be32(fmt);
-       head->h_size = cpu_to_be32(MAX(sunit, XLOG_BIG_RECORD_BSIZE));
+       head->h_size = cpu_to_be32(max(sunit, XLOG_BIG_RECORD_BSIZE));
 
        head->h_lsn = cpu_to_be64(lsn);
        head->h_tail_lsn = cpu_to_be64(tail_lsn);
@@ -346,7 +346,7 @@ libxfs_log_header(
         * minimum (1 hdr blk + 1 data blk). The record length is the total
         * minus however many header blocks are required.
         */
-       head->h_len = cpu_to_be32(MAX(BBTOB(2), sunit) - hdrs * BBSIZE);
+       head->h_len = cpu_to_be32(max(BBTOB(2), sunit) - hdrs * BBSIZE);
 
        /*
         * Write out the unmount record, pack the first word into the record
@@ -363,7 +363,7 @@ libxfs_log_header(
         * the cycle. We don't need to pack any of these blocks because the
         * cycle data in the headers has already been zeroed.
         */
-       len = MAX(len, hdrs + 1);
+       len = max(len, hdrs + 1);
        for (i = hdrs + 1; i < len; i++) {
                p = nextfunc(p, BBSIZE, private);
                memset(p, 0, BBSIZE);
index 92c50095024168f395080ac266f77b34ced71790..640c00ef2b67bae32c03dc8bd6189ac9023ee4a1 100644 (file)
@@ -199,7 +199,7 @@ xlog_print_trans_buffer(char **ptr, int len, int *i, int num_ops)
      * memmove to ensure 8-byte alignment for the long longs in
      * buf_log_format_t structure
      */
-    memmove(&lbuf, *ptr, MIN(sizeof(xfs_buf_log_format_t), len));
+    memmove(&lbuf, *ptr, min(sizeof(xfs_buf_log_format_t), len));
     f = &lbuf;
     *ptr += len;
 
@@ -422,7 +422,7 @@ xlog_print_trans_qoff(char **ptr, uint len)
     xfs_qoff_logformat_t *f;
     xfs_qoff_logformat_t lbuf;
 
-    memmove(&lbuf, *ptr, MIN(sizeof(xfs_qoff_logformat_t), len));
+    memmove(&lbuf, *ptr, min(sizeof(xfs_qoff_logformat_t), len));
     f = &lbuf;
     *ptr += len;
     if (len >= sizeof(xfs_qoff_logformat_t)) {
@@ -523,7 +523,7 @@ xlog_print_trans_inode(
      * len can be smaller than struct xfs_inode_log_format
      * if format data is split over operations
      */
-    memmove(&src_lbuf, *ptr, MIN(sizeof(src_lbuf), len));
+    memmove(&src_lbuf, *ptr, min(sizeof(src_lbuf), len));
     (*i)++;                                    /* bump index */
     *ptr += len;
     if (!continued &&
@@ -662,7 +662,7 @@ xlog_print_trans_dquot(char **ptr, int len, int *i, int num_ops)
      * memmove to ensure 8-byte alignment for the long longs in
      * xfs_dq_logformat_t structure
      */
-    memmove(&lbuf, *ptr, MIN(sizeof(xfs_dq_logformat_t), len));
+    memmove(&lbuf, *ptr, min(sizeof(xfs_dq_logformat_t), len));
     f = &lbuf;
     (*i)++;                                    /* bump index */
     *ptr += len;
@@ -712,7 +712,7 @@ xlog_print_trans_icreate(
        struct xfs_icreate_log  icl_buf = {0};
        struct xfs_icreate_log  *icl;
 
-       memmove(&icl_buf, *ptr, MIN(sizeof(struct xfs_icreate_log), len));
+       memmove(&icl_buf, *ptr, min(sizeof(struct xfs_icreate_log), len));
        icl = &icl_buf;
        *ptr += len;
 
@@ -1061,7 +1061,7 @@ xlog_print_rec_head(xlog_rec_header_t *head, int *len, int bad_hdr_warn)
 
     if (print_overwrite) {
        printf(_("cycle num overwrites: "));
-       for (i=0; i< MIN(bbs, XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++)
+       for (i=0; i< min(bbs, XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++)
            printf("%d - 0x%x  ",
                    i,
                    be32_to_cpu(head->h_cycle_data[i]));
index d1952b02df3ca22a0273ec996f20eb8d4c676397..f1f690ef71a318f17aa2162b1518113b65a94774 100644 (file)
@@ -183,7 +183,7 @@ xlog_print_trans_efd(char **ptr, uint len)
         * memmove to ensure 8-byte alignment for the long longs in
         * xfs_efd_log_format_t structure
         */
-       memmove(&lbuf, *ptr, MIN(core_size, len));
+       memmove(&lbuf, *ptr, min(core_size, len));
        f = &lbuf;
        *ptr += len;
        if (len >= core_size) {
@@ -340,7 +340,7 @@ xlog_print_trans_rud(
         * memmove to ensure 8-byte alignment for the long longs in
         * xfs_efd_log_format_t structure
         */
-       memmove(&lbuf, *ptr, MIN(core_size, len));
+       memmove(&lbuf, *ptr, min(core_size, len));
        f = &lbuf;
        *ptr += len;
        if (len >= core_size) {
@@ -483,7 +483,7 @@ xlog_print_trans_cud(
        /* size without extents at end */
        uint core_size = sizeof(struct xfs_cud_log_format);
 
-       memcpy(&lbuf, *ptr, MIN(core_size, len));
+       memcpy(&lbuf, *ptr, min(core_size, len));
        f = &lbuf;
        *ptr += len;
        if (len >= core_size) {
@@ -627,7 +627,7 @@ xlog_print_trans_bud(
        /* size without extents at end */
        uint core_size = sizeof(struct xfs_bud_log_format);
 
-       memcpy(&lbuf, *ptr, MIN(core_size, len));
+       memcpy(&lbuf, *ptr, min(core_size, len));
        f = &lbuf;
        *ptr += len;
        if (len >= core_size) {
index 745dad4b6884d9a5cc07dc7894f739d8e0008f4c..faaad9005370fa585f845c4458195cca2a868fe9 100644 (file)
@@ -233,7 +233,7 @@ logbsize must be an integer multiple of the log
 stripe unit configured at mkfs time.
 .sp
 The default value for version 1 logs is 32768, while the
-default value for version 2 logs is MAX(32768, log_sunit).
+default value for version 2 logs is max(32768, log_sunit).
 .TP
 .BR logdev=device " and " rtdev=device
 Use an external log (metadata journal) and/or real-time device.
index d26555351470fd8a90cd0e6436ce6ef4c352a3c3..1074886a098b77ce6dc75302a74c9cd7588d781a 100644 (file)
@@ -2097,7 +2097,7 @@ validate_inodesize(
                int     maxsz;
 
                fprintf(stderr, _("illegal inode size %d\n"), cfg->inodesize);
-               maxsz = MIN(cfg->blocksize / XFS_MIN_INODE_PERBLOCK,
+               maxsz = min(cfg->blocksize / XFS_MIN_INODE_PERBLOCK,
                            XFS_DINODE_MAX_SIZE);
                if (XFS_DINODE_MIN_SIZE == maxsz)
                        fprintf(stderr,
@@ -2406,10 +2406,10 @@ open_devices(
         * So, we reduce the size (in basic blocks) to a perfect
         * multiple of the sector size, or 1024, whichever is larger.
         */
-       sector_mask = (uint64_t)-1 << (MAX(cfg->sectorlog, 10) - BBSHIFT);
+       sector_mask = (uint64_t)-1 << (max(cfg->sectorlog, 10) - BBSHIFT);
        xi->dsize &= sector_mask;
        xi->rtsize &= sector_mask;
-       xi->logBBsize &= (uint64_t)-1 << (MAX(cfg->lsectorlog, 10) - BBSHIFT);
+       xi->logBBsize &= (uint64_t)-1 << (max(cfg->lsectorlog, 10) - BBSHIFT);
 
 
        if (!discard)
@@ -2993,12 +2993,12 @@ calculate_log_size(
        libxfs_umount(&mount);
 
        ASSERT(min_logblocks);
-       min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
+       min_logblocks = max(XFS_MIN_LOG_BLOCKS, min_logblocks);
 
        /* if we have lots of blocks, check against XFS_MIN_LOG_BYTES, too */
        if (!cli->logsize &&
            cfg->dblocks >= (1024*1024*1024) >> cfg->blocklog)
-               min_logblocks = MAX(min_logblocks,
+               min_logblocks = max(min_logblocks,
                                    XFS_MIN_LOG_BYTES >> cfg->blocklog);
 
        /*
@@ -3034,7 +3034,7 @@ _("external log device %lld too small, must be at least %lld blocks\n"),
                         * XFS_MIN_LOG_BYTES for filesystems smaller than 16G if
                         * at all possible, ramping up to 128MB at 256GB.
                         */
-                       cfg->logblocks = MIN(XFS_MIN_LOG_BYTES >> cfg->blocklog,
+                       cfg->logblocks = min(XFS_MIN_LOG_BYTES >> cfg->blocklog,
                                        min_logblocks * XFS_DFL_LOG_FACTOR);
                } else {
                        /*
@@ -3048,7 +3048,7 @@ _("external log device %lld too small, must be at least %lld blocks\n"),
                }
 
                /* Ensure the chosen size meets minimum log size requirements */
-               cfg->logblocks = MAX(min_logblocks, cfg->logblocks);
+               cfg->logblocks = max(min_logblocks, cfg->logblocks);
 
                /*
                 * Make sure the log fits wholly within an AG
@@ -3060,11 +3060,11 @@ _("external log device %lld too small, must be at least %lld blocks\n"),
                 * opened to decide what is the valid maximum size of a log in
                 * an AG.
                 */
-               cfg->logblocks = MIN(cfg->logblocks,
+               cfg->logblocks = min(cfg->logblocks,
                                     libxfs_alloc_ag_max_usable(mp) - 1);
 
                /* and now clamp the size to the maximum supported size */
-               cfg->logblocks = MIN(cfg->logblocks, XFS_MAX_LOG_BLOCKS);
+               cfg->logblocks = min(cfg->logblocks, XFS_MAX_LOG_BLOCKS);
                if ((cfg->logblocks << cfg->blocklog) > XFS_MAX_LOG_BYTES)
                        cfg->logblocks = XFS_MAX_LOG_BYTES >> cfg->blocklog;
 
index c7f64121eb4236d7fcb3e5cb2dc2b9adfb7c0b71..50470aba7b05bc1d2fb40d55bf58e36b950937f6 100644 (file)
@@ -29,7 +29,7 @@ time_to_string(
                timer = origin;
        } else {
                time(&now);
-               timer = MAX(origin - now, 0);
+               timer = max(origin - now, 0);
        }
 
        /*
index f343fa8febc502a7e5e2386148df8dba16dedad7..1d04500ffe2f79997b0980196eb7e29eabdede70 100644 (file)
@@ -427,7 +427,7 @@ rmtval_get(xfs_mount_t *mp, xfs_ino_t ino, blkmap_t *blkmap,
 
                ASSERT(mp->m_sb.sb_blocksize == bp->b_bcount);
 
-               length = MIN(bp->b_bcount - hdrsize, valuelen - amountdone);
+               length = min(bp->b_bcount - hdrsize, valuelen - amountdone);
                memmove(value, bp->b_addr + hdrsize, length);
                amountdone += length;
                value += length;
index 375098a911b0e89bfa431e43a7a7142337bcc662..44e43ab48b4298b377093f634699f1da9473d75e 100644 (file)
@@ -178,7 +178,7 @@ blkmap_getn(
                                                nb * sizeof(bmap_ext_t));
 
                bmp[nex].startblock = ext->startblock + (o - ext->startoff);
-               bmp[nex].blockcount = MIN(nb, ext->blockcount -
+               bmp[nex].blockcount = min(nb, ext->blockcount -
                                (bmp[nex].startblock - ext->startblock));
                o += bmp[nex].blockcount;
                nb -= bmp[nex].blockcount;
index 34f197bb9bb2150152f4f9764d579dd487a1e3ba..dd7717be5150874f3d5d4611cfc490aa8e3cef54 100644 (file)
@@ -846,7 +846,7 @@ btree_insert_shift_to_prev(
        if (!btree_copy_cursor_prev(root, tmp_cursor, level + 1))
                return -1;
 
-       n = MIN(*index, (BTREE_PTR_MAX - tmp_cursor[level].node->num_keys) / 2);
+       n = min(*index, (BTREE_PTR_MAX - tmp_cursor[level].node->num_keys) / 2);
        if (!n || !btree_shift_to_prev(root, level, tmp_cursor, n))
                return -1;
 
@@ -869,7 +869,7 @@ btree_insert_shift_to_next(
        if (!btree_copy_cursor_next(root, tmp_cursor, level + 1))
                return -1;
 
-       n = MIN(BTREE_KEY_MAX - *index,
+       n = min(BTREE_KEY_MAX - *index,
                (BTREE_PTR_MAX - tmp_cursor[level].node->num_keys) / 2);
        if (!n || !btree_shift_to_next(root, level, tmp_cursor, n))
                return -1;
index 8705e8c990618015b80b987da6d2fdd5121af59d..379f85cf1268e940e9fc00640a2354d80c10c90b 100644 (file)
@@ -790,10 +790,10 @@ get_agino_buf(
         * we must find the buffer for its cluster, add the appropriate
         * offset, and return that.
         */
-       cluster_size = MAX(mp->m_inode_cluster_size, mp->m_sb.sb_blocksize);
+       cluster_size = max(mp->m_inode_cluster_size, mp->m_sb.sb_blocksize);
        ino_per_cluster = cluster_size / mp->m_sb.sb_inodesize;
        cluster_agino = agino & ~(ino_per_cluster - 1);
-       cluster_blks = XFS_FSB_TO_DADDR(mp, MAX(1,
+       cluster_blks = XFS_FSB_TO_DADDR(mp, max(1,
                        mp->m_inode_cluster_size >> mp->m_sb.sb_blocklog));
        cluster_daddr = XFS_AGB_TO_DADDR(mp, agno,
                        XFS_AGINO_TO_AGBNO(mp, cluster_agino));
@@ -1363,7 +1363,7 @@ _("Bad symlink buffer CRC, block %" PRIu64 ", inode %" PRIu64 ".\n"
                }
 
                byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
-               byte_cnt = MIN(pathlen, byte_cnt);
+               byte_cnt = min(pathlen, byte_cnt);
 
                src = bp->b_addr;
                if (xfs_sb_version_hascrc(&mp->m_sb)) {
index 818e4f676da3675db39a9418eddfb669e95f6b66..1374ddefe06e42b4266dcfd2da061e42ab11f287 100644 (file)
@@ -150,7 +150,7 @@ get_bmap_ext(
                if (blen) {
                        if (!btree_peek_next(ag_bmap[agno], &key))
                                return -1;
-                       *blen = MIN(maxbno, key) - agbno;
+                       *blen = min(maxbno, key) - agbno;
                }
                return *statep;
        }
@@ -159,7 +159,7 @@ get_bmap_ext(
        if (!statep)
                return -1;
        if (blen)
-               *blen = MIN(maxbno, key) - agbno;
+               *blen = min(maxbno, key) - agbno;
 
        return *statep;
 }
index fe41853b671e5c3cf7c9b10776e1d12a98a82f2b..ed10d064d0a61ad35be414d37230de34784c85de 100644 (file)
@@ -430,7 +430,7 @@ clear_uncertain_ino_cache(xfs_agnumber_t agno)
  * XFS_INODES_PER_CHUNK (64) inode chunk
  *
  * Each inode resides in a 64-inode chunk which can be part one or more chunks
- * (MAX(64, inodes-per-block).  The fs allocates in chunks (as opposed to 1
+ * (max(64, inodes-per-block).  The fs allocates in chunks (as opposed to 1
  * chunk) when a block can hold more than one chunk (inodes per block > 64).
  * Allocating in one chunk pieces causes us problems when it takes more than
  * one fs block to contain an inode chunk because the chunks can start on
index ebfcac2d7739e334856078acbe085cb6d18a6f64..9571b2491722e07668ff8cca79b845dd13f9fa09 100644 (file)
@@ -479,7 +479,7 @@ pf_batch_read(
                num = 0;
                if (which == PF_SECONDARY) {
                        bplist[0] = btree_find(args->io_queue, 0, &fsbno);
-                       max_fsbno = MIN(fsbno + pf_max_fsbs,
+                       max_fsbno = min(fsbno + pf_max_fsbs,
                                                        args->last_bno_read);
                } else {
                        bplist[0] = btree_find(args->io_queue,
index 04c7dc2187133e704e6096f208b5ac46fd52ec8f..41ab3017b22bf7a16873ce5b8dd147f1e8b9d2b1 100644 (file)
@@ -748,7 +748,7 @@ main(int argc, char **argv)
 
        chunks_pblock = mp->m_sb.sb_inopblock / XFS_INODES_PER_CHUNK;
        max_symlink_blocks = libxfs_symlink_blocks(mp, XFS_SYMLINK_MAXLEN);
-       inodes_per_cluster = MAX(mp->m_sb.sb_inopblock,
+       inodes_per_cluster = max(mp->m_sb.sb_inopblock,
                        mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog);
 
        /*
@@ -846,9 +846,9 @@ main(int argc, char **argv)
                        rlim.rlim_cur = rlim.rlim_max;
                        setrlimit(RLIMIT_AS, &rlim);
                        /* use approximately 80% of rlimit to avoid overrun */
-                       max_mem = MIN(max_mem, rlim.rlim_cur / 1280);
+                       max_mem = min(max_mem, rlim.rlim_cur / 1280);
                } else
-                       max_mem = MIN(max_mem, (LONG_MAX >> 10) + 1);
+                       max_mem = min(max_mem, (LONG_MAX >> 10) + 1);
 
                if (verbose > 1)
                        do_log(