All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: don't cast string literals
@ 2015-05-13 23:16 Eric Sandeen
  2015-05-14 14:21 ` Brian Foster
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2015-05-13 23:16 UTC (permalink / raw)
  To: xfs-oss

The commit:

a9273ca5 xfs: convert attr to use unsigned names

added these (unsigned char *) casts, but then the _SIZE macros
return "7" - size of a pointer minus one - not the length of
the string.  This is harmless in the kernel, because the _SIZE
macros are not used, but as we sync up with userspace, this will
matter.

I don't think the cast is necessary; i.e. assigning the string
literal to an unsigned char *, or passing it to a function
expecting an unsigned char *, should be ok, right?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

I can send the xfsprogs version if you like, if this passes
muster ;)

(the other option is to cast it back to a (char *) in the sizeof
but then things are just getting weird IMHO...)

diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 4daaa66..ff22a4d 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -1453,8 +1453,8 @@ struct xfs_acl {
 		sizeof(struct xfs_acl_entry) * XFS_ACL_MAX_ENTRIES((mp)))
 
 /* On-disk XFS extended attribute names */
-#define SGI_ACL_FILE		(unsigned char *)"SGI_ACL_FILE"
-#define SGI_ACL_DEFAULT		(unsigned char *)"SGI_ACL_DEFAULT"
+#define SGI_ACL_FILE		"SGI_ACL_FILE"
+#define SGI_ACL_DEFAULT		"SGI_ACL_DEFAULT"
 #define SGI_ACL_FILE_SIZE	(sizeof(SGI_ACL_FILE)-1)
 #define SGI_ACL_DEFAULT_SIZE	(sizeof(SGI_ACL_DEFAULT)-1)
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xfs: don't cast string literals
  2015-05-13 23:16 [PATCH] xfs: don't cast string literals Eric Sandeen
@ 2015-05-14 14:21 ` Brian Foster
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Foster @ 2015-05-14 14:21 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On Wed, May 13, 2015 at 06:16:48PM -0500, Eric Sandeen wrote:
> The commit:
> 
> a9273ca5 xfs: convert attr to use unsigned names
> 
> added these (unsigned char *) casts, but then the _SIZE macros
> return "7" - size of a pointer minus one - not the length of
> the string.  This is harmless in the kernel, because the _SIZE
> macros are not used, but as we sync up with userspace, this will
> matter.
> 
> I don't think the cast is necessary; i.e. assigning the string
> literal to an unsigned char *, or passing it to a function
> expecting an unsigned char *, should be ok, right?
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> I can send the xfsprogs version if you like, if this passes
> muster ;)
> 
> (the other option is to cast it back to a (char *) in the sizeof
> but then things are just getting weird IMHO...)
> 

Heh, the cast inside the directive looks weird enough to me in the first
place. In this case it seems spurious, so I'm fine with it:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> index 4daaa66..ff22a4d 100644
> --- a/fs/xfs/libxfs/xfs_format.h
> +++ b/fs/xfs/libxfs/xfs_format.h
> @@ -1453,8 +1453,8 @@ struct xfs_acl {
>  		sizeof(struct xfs_acl_entry) * XFS_ACL_MAX_ENTRIES((mp)))
>  
>  /* On-disk XFS extended attribute names */
> -#define SGI_ACL_FILE		(unsigned char *)"SGI_ACL_FILE"
> -#define SGI_ACL_DEFAULT		(unsigned char *)"SGI_ACL_DEFAULT"
> +#define SGI_ACL_FILE		"SGI_ACL_FILE"
> +#define SGI_ACL_DEFAULT		"SGI_ACL_DEFAULT"
>  #define SGI_ACL_FILE_SIZE	(sizeof(SGI_ACL_FILE)-1)
>  #define SGI_ACL_DEFAULT_SIZE	(sizeof(SGI_ACL_DEFAULT)-1)
>  
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-14 14:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-13 23:16 [PATCH] xfs: don't cast string literals Eric Sandeen
2015-05-14 14:21 ` Brian Foster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.