]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: push down unsigned char casts
authorChristoph Hellwig <hch@lst.de>
Wed, 31 Jul 2024 17:23:01 +0000 (10:23 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 31 Jul 2024 17:23:01 +0000 (10:23 -0700)
Source kernel commit: 9392ed7300c3b4e70778156de1bc84a4c40c413b

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>
libxfs/xfs_attr.c
libxfs/xfs_attr.h
libxfs/xfs_attr_leaf.c
libxfs/xfs_da_btree.c
libxfs/xfs_da_btree.h
libxfs/xfs_dir2.c
libxfs/xfs_dir2_block.c
libxfs/xfs_dir2_data.c
libxfs/xfs_parent.c
libxfs/xfs_parent.h
libxfs/xfs_types.h

index 9e1cce5776b3dfbe3e317d396bf34efe78196000..e89b09d2cb6957f8855f22c5db7e4abd8125249f 100644 (file)
@@ -412,7 +412,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);
@@ -423,7 +423,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 ce20d81a486988ec7b4c37e723af84979c491f3c..684b838b75cd04987876d55b727d8e4bba46c865 100644 (file)
@@ -979,7 +979,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;
@@ -1191,7 +1191,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 820e8575246b50f8e6d8ad89f774c9357ea87b71..29386c702eb96cfa45c72231ebd9b42ca9283483 100644 (file)
@@ -2246,8 +2246,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 5f7ebbf161695c66cf3d962fea07fa9f74fedb51..f5170b75cd3f9636e33d62c4d40434b2ae14f255 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 82da0d3275e36632a21bd3e119eceedab44f7857..f1eeaf26b644390528092c443f6f82e68b609bcd 100644 (file)
@@ -37,8 +37,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
@@ -1246,7 +1246,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 65e6ed8791ed9f3440a6b4c6aa2ad0dd975f0478..8f15fe54c9ce60b21562dd58c61ed858443ed6e5 100644 (file)
@@ -252,7 +252,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 84220f10a1f409ae5b8a0702aa029e5047cc60e2..8fb98f2f328afb22d840f62d5a10755b8c1305fc 100644 (file)
@@ -96,7 +96,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)
 {
@@ -118,7 +118,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)
@@ -266,7 +266,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;
 };