Re: [PATCH] seq_file: fix clang warning for NULL pointer arithmetic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> index f277d023ebcd..b55e6ef4d677 100644
> --- a/fs/kernfs/file.c
> +++ b/fs/kernfs/file.c
> @@ -124,7 +124,7 @@ static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
>  		 * The same behavior and code as single_open().  Returns
>  		 * !NULL if pos is at the beginning; otherwise, NULL.
>  		 */
> -		return NULL + !*ppos;
> +		return (void *)(uintptr_t)!*ppos;

Yikes.  This is just horrible, why bnot the completely obvious:

	if (ops->seq_start) {
		...
		return next;
	}

	if (*ppos)
		return NULL;
	return ppos; /* random cookie */

>  static void *single_start(struct seq_file *p, loff_t *pos)
>  {
> -	return NULL + (*pos == 0);
> +	return (void *)(uintptr_t)(*pos == 0);

Same here.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux