]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libxfs/rdwr.c
xfsprogs: make static things static
[thirdparty/xfsprogs-dev.git] / libxfs / rdwr.c
index ae6198844509d8ec700bd15aef1839a7f45477ef..753b9396fbe538dafe9cde701704827ab7cf1740 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 
@@ -143,7 +131,7 @@ static char *next(
        struct xfs_buf  *buf = (struct xfs_buf *)private;
 
        if (buf &&
-           (XFS_BUF_COUNT(buf) < (int)(ptr - XFS_BUF_PTR(buf)) + offset))
+           (buf->b_bcount < (int)(ptr - (char *)buf->b_addr) + offset))
                abort();
 
        return ptr + offset;
@@ -193,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;
@@ -204,7 +192,7 @@ libxfs_log_clear(
        ptr = dptr;
        if (btp) {
                bp = libxfs_getbufr(btp, start, len);
-               ptr = XFS_BUF_PTR(bp);
+               ptr = bp->b_addr;
        }
        libxfs_log_header(ptr, fs_uuid, version, sunit, fmt, lsn, tail_lsn,
                          next, bp);
@@ -252,7 +240,7 @@ libxfs_log_clear(
                ptr = dptr;
                if (btp) {
                        bp = libxfs_getbufr(btp, blk, len);
-                       ptr = XFS_BUF_PTR(bp);
+                       ptr = bp->b_addr;
                }
                /*
                 * Note: pass the full buffer length as the sunit to initialize
@@ -307,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);
@@ -358,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
@@ -375,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);
@@ -556,7 +544,7 @@ libxfs_bcompare(struct cache_node *node, cache_key_t key)
        return CACHE_MISS;
 }
 
-void
+static void
 libxfs_bprint(xfs_buf_t *bp)
 {
        fprintf(stderr, "Buffer %p blkno=%llu bytes=%u flags=0x%x count=%u\n",
@@ -636,7 +624,7 @@ libxfs_initbuf_map(xfs_buf_t *bp, struct xfs_buftarg *btp,
        bp->b_flags |= LIBXFS_B_DISCONTIG;
 }
 
-xfs_buf_t *
+static xfs_buf_t *
 __libxfs_getbufr(int blen)
 {
        xfs_buf_t       *bp;
@@ -693,7 +681,7 @@ libxfs_getbufr(struct xfs_buftarg *btp, xfs_daddr_t blkno, int bblen)
        return bp;
 }
 
-xfs_buf_t *
+static xfs_buf_t *
 libxfs_getbufr_map(struct xfs_buftarg *btp, xfs_daddr_t blkno, int bblen,
                struct xfs_buf_map *map, int nmaps)
 {
@@ -791,7 +779,7 @@ struct xfs_buf *
 libxfs_getbuf_flags(struct xfs_buftarg *btp, xfs_daddr_t blkno, int len,
                unsigned int flags)
 {
-       struct xfs_bufkey key = {0};
+       struct xfs_bufkey key = {NULL};
 
        key.buftarg = btp;
        key.blkno = blkno;
@@ -834,7 +822,7 @@ static struct xfs_buf *
 __libxfs_getbuf_map(struct xfs_buftarg *btp, struct xfs_buf_map *map,
                    int nmaps, int flags)
 {
-       struct xfs_bufkey key = {0};
+       struct xfs_bufkey key = {NULL};
        int i;
 
        if (nmaps == 1)
@@ -894,7 +882,7 @@ libxfs_putbuf(xfs_buf_t *bp)
 void
 libxfs_purgebuf(xfs_buf_t *bp)
 {
-       struct xfs_bufkey key = {0};
+       struct xfs_bufkey key = {NULL};
 
        key.buftarg = bp->b_target;
        key.blkno = bp->b_bn;
@@ -1026,7 +1014,7 @@ libxfs_readbufr_map(struct xfs_buftarg *btp, struct xfs_buf *bp, int flags)
 {
        int     fd;
        int     error = 0;
-       char    *buf;
+       void    *buf;
        int     i;
 
        fd = libxfs_device_to_fd(btp->dev);
@@ -1147,7 +1135,7 @@ libxfs_writebufr(xfs_buf_t *bp)
                                    LIBXFS_BBTOOFF64(bp->b_bn), bp->b_flags);
        } else {
                int     i;
-               char    *buf = bp->b_addr;
+               void    *buf = bp->b_addr;
 
                for (i = 0; i < bp->b_nmaps; i++) {
                        off64_t offset = LIBXFS_BBTOOFF64(bp->b_maps[i].bm_bn);
@@ -1414,7 +1402,7 @@ libxfs_iget(
        }
 
        if (!libxfs_inode_verify_forks(ip, ifork_ops)) {
-               libxfs_iput(ip);
+               libxfs_irele(ip);
                return -EFSCORRUPTED;
        }
 
@@ -1447,7 +1435,8 @@ libxfs_idestroy(xfs_inode_t *ip)
 }
 
 void
-libxfs_iput(xfs_inode_t *ip)
+libxfs_irele(
+       struct xfs_inode        *ip)
 {
        if (ip->i_itemp)
                kmem_zone_free(xfs_ili_zone, ip->i_itemp);