]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: push down unsigned char casts xfs-unsigned-char
authorChristoph Hellwig <hch@lst.de>
Wed, 31 Jul 2024 17:20:05 +0000 (10:20 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 31 Jul 2024 17:20:05 +0000 (10:20 -0700)
To get us of casting hell, push down the casts to the unsigned char
to the low-level hash code and the on-disk format definitions.  The
hash code is the only place that actually cares about the signedness.

The on-disk format would be cleaner by not using it, but using it
is a correct headsup to worry about the signedness.

Note that right now this only really matters for userspace, as the
kernel forces -funsigned-char for all architectures.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr.h
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_da_btree.c
fs/xfs/libxfs/xfs_da_btree.h
fs/xfs/libxfs/xfs_dir2.c
fs/xfs/libxfs/xfs_dir2_block.c
fs/xfs/libxfs/xfs_dir2_data.c
fs/xfs/libxfs/xfs_parent.c
fs/xfs/libxfs/xfs_parent.h
fs/xfs/libxfs/xfs_types.h

index f30bcc64100d56b7199fc6b73ee777f6a6e06aa9..a03d9f5dc8430fddb2e3453575947ca10c7e8bed 100644 (file)
@@ -413,7 +413,7 @@ out:
 /* Compute the hash value for a user/root/secure extended attribute */
 xfs_dahash_t
 xfs_attr_hashname(
-       const uint8_t           *name,
+       const char              *name,
        int                     namelen)
 {
        return xfs_da_hashname(name, namelen);
@@ -424,7 +424,7 @@ xfs_dahash_t
 xfs_attr_hashval(
        struct xfs_mount        *mp,
        unsigned int            attr_flags,
-       const uint8_t           *name,
+       const char              *name,
        int                     namelen,
        const void              *value,
        int                     valuelen)
index 0e51d0723f9aa36c1519f6ad2c1881489a26dd8a..a1079ef94f1f048f0a3c8abd6061abae98dce2af 100644 (file)
@@ -628,10 +628,10 @@ xfs_attr_init_replace_state(struct xfs_da_args *args)
        return xfs_attr_init_add_state(args);
 }
 
-xfs_dahash_t xfs_attr_hashname(const uint8_t *name, int namelen);
+xfs_dahash_t xfs_attr_hashname(const char *name, int namelen);
 
 xfs_dahash_t xfs_attr_hashval(struct xfs_mount *mp, unsigned int attr_flags,
-               const uint8_t *name, int namelen, const void *value,
+               const char *name, int namelen, const void *value,
                int valuelen);
 
 /* Set the hash value for any extended attribute from any namespace. */
index b9e98950eb3d81c3cf90e996e34584ce3a82ca6c..028c99e1468d476de70fdd586f210732c28d6d52 100644 (file)
@@ -982,7 +982,7 @@ xfs_attr_shortform_to_leaf(
 
        sfe = xfs_attr_sf_firstentry(sf);
        for (i = 0; i < sf->count; i++) {
-               nargs.name = sfe->nameval;
+               nargs.name = (const char *)sfe->nameval;
                nargs.namelen = sfe->namelen;
                nargs.value = &sfe->nameval[nargs.namelen];
                nargs.valuelen = sfe->valuelen;
@@ -1194,7 +1194,7 @@ xfs_attr3_leaf_to_shortform(
                        continue;
                ASSERT(entry->flags & XFS_ATTR_LOCAL);
                name_loc = xfs_attr3_leaf_name_local(leaf, i);
-               nargs.name = name_loc->nameval;
+               nargs.name = (const char *)name_loc->nameval;
                nargs.namelen = name_loc->namelen;
                nargs.value = &name_loc->nameval[nargs.namelen];
                nargs.valuelen = be16_to_cpu(name_loc->valuelen);
index 16a529a8878083aee350d746c2d98fd307b83cef..bd4eaa5967c58843c3231c7724c03ae937179cda 100644 (file)
@@ -2250,8 +2250,9 @@ xfs_da3_path_shift(
  * This is implemented with some source-level loop unrolling.
  */
 xfs_dahash_t
-xfs_da_hashname(const uint8_t *name, int namelen)
+xfs_da_hashname(const char *_name, int namelen)
 {
+       const uint8_t *name = (const uint8_t *)_name;
        xfs_dahash_t hash;
 
        /*
index 354d5d65043e432af0261297f16f198c82fd636d..aef9bd61cbde7abc077a81a5af6daf2770da70a8 100644 (file)
@@ -54,8 +54,8 @@ enum xfs_dacmp {
  */
 typedef struct xfs_da_args {
        struct xfs_da_geometry *geo;    /* da block geometry */
-       const uint8_t   *name;          /* string (maybe not NULL terminated) */
-       const uint8_t   *new_name;      /* new attr name */
+       const char      *name;          /* string (maybe not NULL terminated) */
+       const char      *new_name;      /* new attr name */
        void            *value;         /* set of bytes (maybe contain NULLs) */
        void            *new_value;     /* new xattr value (may contain NULLs) */
        struct xfs_inode *dp;           /* directory inode to manipulate */
@@ -224,7 +224,7 @@ int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,
 void   xfs_da_buf_copy(struct xfs_buf *dst, struct xfs_buf *src,
                        size_t size);
 
-uint xfs_da_hashname(const uint8_t *name_string, int name_length);
+uint xfs_da_hashname(const char *name_string, int name_length);
 enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
                                const unsigned char *name, int len);
 
index 202468223bf9437a61a43472ca27f0fc6a9ba975..7d77c27bceae81eeeb61c926738cb518da32618a 100644 (file)
 #include "xfs_ialloc.h"
 
 const struct xfs_name xfs_name_dotdot = {
-       .name   = (const unsigned char *)"..",
+       .name   = "..",
        .len    = 2,
        .type   = XFS_DIR3_FT_DIR,
 };
 
 const struct xfs_name xfs_name_dot = {
-       .name   = (const unsigned char *)".",
+       .name   = ".",
        .len    = 1,
        .type   = XFS_DIR3_FT_DIR,
 };
index 0f93ed1a4a74f412d20bb6a6cf173331d1667c7f..2d80ffb6eb850142e26da5c97dd1db43ddc45b1f 100644 (file)
@@ -40,8 +40,8 @@ static xfs_dahash_t xfs_dir_hash_dot, xfs_dir_hash_dotdot;
 void
 xfs_dir_startup(void)
 {
-       xfs_dir_hash_dot = xfs_da_hashname((unsigned char *)".", 1);
-       xfs_dir_hash_dotdot = xfs_da_hashname((unsigned char *)"..", 2);
+       xfs_dir_hash_dot = xfs_da_hashname(".", 1);
+       xfs_dir_hash_dotdot = xfs_da_hashname("..", 2);
 }
 
 static xfs_failaddr_t
@@ -1249,7 +1249,7 @@ xfs_dir2_sf_to_block(
                tagp = xfs_dir2_data_entry_tag_p(mp, dep);
                *tagp = cpu_to_be16(newoffset);
                xfs_dir2_data_log_entry(args, bp, dep);
-               name.name = sfep->name;
+               name.name = (char *)sfep->name;
                name.len = sfep->namelen;
                blp[2 + i].hashval = cpu_to_be32(xfs_dir2_hashname(mp, &name));
                blp[2 + i].address =
index a16b05c43e2ece79efefc928b2d40f6093640422..cabb8b45bf14920aa0fae2c4e491f1e4f2ef228e 100644 (file)
@@ -255,7 +255,7 @@ __xfs_dir3_data_check(
                        addr = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
                                                (xfs_dir2_data_aoff_t)
                                                ((char *)dep - (char *)hdr));
-                       name.name = dep->name;
+                       name.name = (char *)dep->name;
                        name.len = dep->namelen;
                        hash = xfs_dir2_hashname(mp, &name);
                        for (i = 0; i < be32_to_cpu(btp->count); i++) {
index 69366c44a701599799481eb178f382bd0b7c4028..15902c0f046a85d8cf1fa7e97be6e50085e55c70 100644 (file)
@@ -99,7 +99,7 @@ xfs_parent_valuecheck(
 xfs_dahash_t
 xfs_parent_hashval(
        struct xfs_mount                *mp,
-       const uint8_t                   *name,
+       const char                      *name,
        int                             namelen,
        xfs_ino_t                       parent_ino)
 {
@@ -121,7 +121,7 @@ xfs_parent_hashval(
 xfs_dahash_t
 xfs_parent_hashattr(
        struct xfs_mount                *mp,
-       const uint8_t                   *name,
+       const char                      *name,
        int                             namelen,
        const void                      *value,
        int                             valuelen)
@@ -269,7 +269,7 @@ int
 xfs_parent_from_attr(
        struct xfs_mount        *mp,
        unsigned int            attr_flags,
-       const unsigned char     *name,
+       const char              *name,
        unsigned int            namelen,
        const void              *value,
        unsigned int            valuelen,
index b8036527cdc73c9702f083bf32746d6064b0c21f..650307981fe1334107ab22e3cdd5c932074560a2 100644 (file)
@@ -12,9 +12,9 @@ bool xfs_parent_namecheck(unsigned int attr_flags, const void *name,
 bool xfs_parent_valuecheck(struct xfs_mount *mp, const void *value,
                size_t valuelen);
 
-xfs_dahash_t xfs_parent_hashval(struct xfs_mount *mp, const uint8_t *name,
+xfs_dahash_t xfs_parent_hashval(struct xfs_mount *mp, const char *name,
                int namelen, xfs_ino_t parent_ino);
-xfs_dahash_t xfs_parent_hashattr(struct xfs_mount *mp, const uint8_t *name,
+xfs_dahash_t xfs_parent_hashattr(struct xfs_mount *mp, const char *name,
                int namelen, const void *value, int valuelen);
 
 /* Initializes a xfs_parent_rec to be stored as an attribute name. */
@@ -92,7 +92,7 @@ int xfs_parent_replacename(struct xfs_trans *tp,
                struct xfs_inode *child);
 
 int xfs_parent_from_attr(struct xfs_mount *mp, unsigned int attr_flags,
-               const unsigned char *name, unsigned int namelen,
+               const char *name, unsigned int namelen,
                const void *value, unsigned int valuelen,
                xfs_ino_t *parent_ino, uint32_t *parent_gen);
 
index 76eb9e328835f8be1a7135d15704462e2365aa42..250501614966cfb8a4bb8949bdac7acda3c8533b 100644 (file)
@@ -117,7 +117,7 @@ typedef enum {
        { XFS_LOOKUP_GEi,       "ge" }
 
 struct xfs_name {
-       const unsigned char     *name;
+       const char              *name;
        int                     len;
        int                     type;
 };