Use SEEK_{SET,CUR,END} instead of hardcoded values
Subsystems (8)
PATCH 1/1 Use SEEK_{SET,CUR,END} instead of hardcoded values
In July, David Howells added SEEK_{SET,CUR,END} definitions to include/linux/fs.h
The following patches convert offenders which were found by grep'ing the source tree.
Josef 'Jeff' Sipek
11 files changed, 34 insertions(+), 39 deletions(-) drivers/char/mbcs.c | 7 ++++--- drivers/isdn/hardware/eicon/dsp_defs.h | 3 --- drivers/mtd/mtdchar.c | 11 ++++------- fs/cifs/cifsfs.c | 2 +- fs/locks.c | 12 ++++++------ fs/nfs/file.c | 2 +- fs/xfs/xfs_vnodeops.c | 6 +++--- sound/core/info.c | 6 +++--- sound/drivers/opl4/opl4_proc.c | 6 +++--- sound/isa/gus/gus_mem_proc.c | 6 +++--- sound/pci/mixart/mixart.c | 12 ++++++------
PATCH 1/1 MBCS: Use SEEK_{SET, CUR, END} instead of hardcoded values
MBCS: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
drivers/char/mbcs.c +4 -3
@@ -22,6 +22,7 @@#include <linux/delay.h> #include <linux/device.h> #include <linux/mm.h> +#include <linux/fs.h> #include <linux/uio.h> #include <asm/io.h> #include <asm/uaccess.h>
@@ -447,15 +448,15 @@ loff_t mbcs_sram_llseek(struct file * filoff_t newpos;switch (whence) { -case 0 :/* SEEK_SET */ +case SEEK_SET : newpos = off;break ; -case 1 :/* SEEK_CUR */ +case SEEK_CUR : newpos = filp->f_pos + off;break ; -case 2 :/* SEEK_END */ +case SEEK_END : newpos =MBCS_SRAM_SIZE + off;break ;
PATCH 1/1 sound core: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' Sipeksound core: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
sound/core/info.c +3 -3
@@ -174,15 +174,15 @@ static loff_t snd_info_entry_llseek(struswitch (entry->content) {case SNDRV_INFO_CONTENT_TEXT :switch (orig) { -case 0 :/* SEEK_SET */ +case SEEK_SET : file->f_pos = offset; ret = file->f_pos; goto out; -case 1 :/* SEEK_CUR */ +case SEEK_CUR : file->f_pos += offset; ret = file->f_pos; goto out; -case 2 :/* SEEK_END */ +case SEEK_END :default : ret = -EINVAL ; goto out;
PATCH 1/1 opl4: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' Sipekopl4: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
sound/drivers/opl4/opl4_proc.c +3 -3
@@ -105,13 +105,13 @@ static long long snd_opl4_mem_proc_llsee struct file *file, long long offset, int orig) { switch (orig) { -case 0 :/* SEEK_SET */ + case SEEK_SET: file->f_pos = offset;break ; -case 1 :/* SEEK_CUR */ +case SEEK_CUR : file->f_pos += offset;break ; -case 2 :/* SEEK_END, offset is negative */ +case SEEK_END :/* offset is negative */ file->f_pos = entry->size + offset;break ;default :
PATCH 1/1 EICON ISDN: Removed unused definitions for OS_SEEK_*
In reply to Josef 'Jeff' SipekEICON ISDN: Removed unused definitions for OS_SEEK_*
--
drivers/isdn/hardware/eicon/dsp_defs.h +0 -3
@@ -34,9 +34,6 @@* * I/O functions returns -1 on error, 0 on EOF */ -#define OS_SEEK_SET 0 -#define OS_SEEK_CUR 1 -#define OS_SEEK_END 2struct _OsFileHandle_ ; typedef long ( * OsFileIo) (struct _OsFileHandle_ *handle, void *buffer,
PATCH 1/1 gus: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' Sipekgus: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
sound/isa/gus/gus_mem_proc.c +3 -3
@@ -61,13 +61,13 @@ static long long snd_gf1_mem_proc_llseekstruct gus_proc_private *priv = entry->private_data;switch (orig) { -case 0 :/* SEEK_SET */ +case SEEK_SET : file->f_pos = offset;break ; -case 1 :/* SEEK_CUR */ +case SEEK_CUR : file->f_pos += offset;break ; -case 2 :/* SEEK_END, offset is negative */ +case SEEK_END :/* offset is negative */ file->f_pos = priv->size + offset;break ;default :
PATCH 1/1 CIFS: Use SEEK_END instead of hardcoded value
In reply to Josef 'Jeff' SipekCIFS: Use SEEK_END instead of hardcoded value
--
fs/cifs/cifsfs.c +1 -1
@@ -510,7 +510,7 @@ static loff_t cifs_llseek(struct file *fstatic loff_t cifs_llseek (struct file *file,loff_t offset,int origin) {/* origin == SEEK_END => we must revalidate the cached file length */ -if (origin ==2 ) { +if (origin ==SEEK_END ) {int retval =cifs_revalidate (file->f_dentry);if (retval <0 )return (loff_t )retval;
PATCH 1/1 mixart: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' Sipekmixart: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
sound/pci/mixart/mixart.c +6 -6
@@ -1109,13 +1109,13 @@ static long long snd_mixart_BA0_llseek(s offset = offset & ~3 ;/* 4 bytes aligned */ switch (orig) { -case 0 :/* SEEK_SET */ +case SEEK_SET : file->f_pos = offset;break ; -case 1 :/* SEEK_CUR */ +case SEEK_CUR : file->f_pos += offset;break ; -case 2 :/* SEEK_END, offset is negative */ +case SEEK_END :/* offset is negative */ file->f_pos =MIXART_BA0_SIZE + offset;break ;default :
@@ -1135,13 +1135,13 @@ static long long snd_mixart_BA1_llseek(s offset = offset & ~3 ;/* 4 bytes aligned */ switch (orig) { -case 0 :/* SEEK_SET */ +case SEEK_SET : file->f_pos = offset;break ; -case 1 :/* SEEK_CUR */ +case SEEK_CUR : file->f_pos += offset;break ; -case 2 :/* SEEK_END, offset is negative */ +case SEEK_END :/* offset is negative */ file->f_pos =MIXART_BA1_SIZE + offset;break ;default :
PATCH 1/1 XFS: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' SipekXFS: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
fs/xfs/xfs_vnodeops.c +3 -3
@@ -4510,12 +4510,12 @@ xfs_change_file_space(xfs_iunlock (ip,XFS_ILOCK_SHARED );switch (bf->l_whence) { -case 0 :/*SEEK_SET*/ +case SEEK_SET :break ; -case 1 :/*SEEK_CUR*/ +case SEEK_CUR : bf->l_start += offset;break ; -case 2 :/*SEEK_END*/ +case SEEK_END : bf->l_start += ip->i_d.di_size;break ;default :
PATCH 1/1 NFS: Use SEEK_END instead of hardcoded value
In reply to Josef 'Jeff' SipekNFS: Use SEEK_END instead of hardcoded value
--
fs/nfs/file.c +1 -1
@@ -157,7 +157,7 @@ static loff_t nfs_file_llseek(struct filstatic loff_t nfs_file_llseek (struct file *filp,loff_t offset,int origin) {/* origin == SEEK_END => we must revalidate the cached file length */ -if (origin ==2 ) { +if (origin ==SEEK_END ) {struct inode *inode = filp->f_mapping->host;int retval =nfs_revalidate_file_size (inode, filp);if (retval <0 )
PATCH 1/1 VFS: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' SipekVFS: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
fs/locks.c +6 -6
@@ -314,13 +314,13 @@ static int flock_to_posix_lock(struct fioff_t start, end;switch (l->l_whence) { -case 0 :/*SEEK_SET*/ +case SEEK_SET : start =0 ;break ; -case 1 :/*SEEK_CUR*/ +case SEEK_CUR : start = filp->f_pos;break ; -case 2 :/*SEEK_END*/ +case SEEK_END : start =i_size_read (filp->f_dentry->d_inode);break ;default :
@@ -364,13 +364,13 @@ static int flock64_to_posix_lock(structloff_t start;switch (l->l_whence) { -case 0 :/*SEEK_SET*/ +case SEEK_SET : start =0 ;break ; -case 1 :/*SEEK_CUR*/ +case SEEK_CUR : start = filp->f_pos;break ; -case 2 :/*SEEK_END*/ +case SEEK_END : start =i_size_read (filp->f_dentry->d_inode);break ;default :
PATCH 1/1 MTD: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' SipekMTD: Use SEEK_{SET,CUR,END} instead of hardcoded values
--
drivers/mtd/mtdchar.c +4 -7
@@ -62,15 +62,12 @@ static loff_t mtd_lseek (struct file *fistruct mtd_info *mtd = mfi->mtd;switch (orig) { -case 0 : -/* SEEK_SET */ -break ; -case 1 : -/* SEEK_CUR */ +case SEEK_SET : +break ; +case SEEK_CUR : offset += file->f_pos;break ; -case 2 : -/* SEEK_END */ +case SEEK_END : offset += mtd->size;break ;default :
Quoted 4 lines · Josef 'Jeff' Sipek
In July, David Howells added SEEK_{SET,CUR,END} definitions to
include/linux/fs.hThe following patches convert offenders which were found by grep'ing the source tree.
Looks like a good change to me.
Nitpick, do you need 11 patches to do it? 1 would be fine, I think?
Signature · 2 lines
SUSE Labs, Novell Inc. Send instant messages to your online friends http://au.messenger.yahoo.com
Quoted 11 lines · Nick Piggin
Quoted 6 lines · Josef 'Jeff' Sipek
In July, David Howells added SEEK_{SET,CUR,END} definitions to
include/linux/fs.hThe following patches convert offenders which were found by grep'ing the source
tree.Looks like a good change to me.
Nitpick, do you need 11 patches to do it? 1 would be fine, I think?
I don't. I just got carried away with Mercurial's patch queues support.
Josef 'Jeff' Sipek.
Signature · 1 line
A computer without Microsoft is like chocolate cake without mustard.
Re: [PATCH 2 of 11] EICON ISDN: Removed unused definitions for OS_SEEK_*
In reply to Josef 'Jeff' SipekAgreed, these defines are not used in the linux kernel. They can be removed.
Armin
Quoted 1 line · Josef 'Jeff' Sipek
EICON ISDN: Removed unused definitions for OS_SEEK_*
--
drivers/isdn/hardware/eicon/dsp_defs.h +0 -3
@@ -34,9 +34,6 @@* * I/O functions returns -1 on error, 0 on EOF */ -#define OS_SEEK_SET 0 -#define OS_SEEK_CUR 1 -#define OS_SEEK_END 2struct _OsFileHandle_ ; typedef long ( * OsFileIo) (struct _OsFileHandle_ *handle, void *buffer,
David Woodhouse
AppliedRe: [PATCH 3 of 11] MTD: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' SipekQuoted 3 lines · Josef 'Jeff' Sipek
MTD: Use SEEK_{SET,CUR,END} instead of hardcoded values
Signed-off-by Josef 'Jeff' Sipek <[email protected]>
Applied to MTD git tree; thanks.
Signature · 1 line
dwmw2
Re: [PATCH 5 of 11] XFS: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to Josef 'Jeff' SipekQuoted 1 line · Josef 'Jeff' Sipek
XFS: Use SEEK_{SET,CUR,END} instead of hardcoded values
The hard coded values used in xfs_change_file_space() are documented as part of the API to the userspace functions that use this interface in xfsctl(3). That is:
XFS_IOC_FREESP
XFS_IOC_FREESP64
XFS_IOC_ALLOCSP
XFS_IOC_ALLOCSP64
Alter storage space associated with a section of the ordinary file specified. The section is specified by a variable of type xfs_flock64_t, pointed to by the final argument. The data type xfs_flock64_t contains the following
members: l_whence is 0, 1, or 2 to indicate that the relative offset l_start will be measured from the start of the file, the current position, or the end of the file, respectively.
Hence I think that the hard coded values should not be changed to something that is defined outside of XFS's API.
Cheers,
Dave.
Signature · 3 lines
Dave Chinner Principal Engineer SGI Australian Software Group
Re: [PATCH 5 of 11] XFS: Use SEEK_{SET, CUR, END} instead of hardcoded values
Quoted 2 lines · David Chinner
The hard coded values used in
xfs_change_file_space()are documented as part of the API to the userspace functions that use this interface in xfsctl(3).
Hmmm... that's a good point. I think you're right on this account, and so the comments in:
case 0: /*SEEK_SET*/ break; case 1: /*SEEK_CUR*/ bf->l_start += offset; break; case 2: /*SEEK_END*/ bf->l_start += ip->i_d.di_size; break;
should be stripped off as they are not exactly correct.
David
Quoted 5 lines · Josef 'Jeff' Sipek
In July, David Howells added SEEK_{SET,CUR,END} definitions to
include/linux/fs.hThe following patches convert offenders which were found by grep'ing the source tree.
Looks good, though I think you do have to drop the XFS portion of the patch, though you could strip the comments from the case statements there.
So NAK for the XFS patch, but for the rest:
Re: [PATCH 5 of 11] XFS: Use SEEK_{SET, CUR, END} instead of hardcoded values
In reply to David HowellsQuoted 17 lines · David Howells
Quoted 2 lines · David Chinner
The hard coded values used in
xfs_change_file_space()are documented as part of the API to the userspace functions that use this interface in xfsctl(3).Hmmm... that's a good point. I think you're right on this account, and so the comments in:
case 0: /*SEEK_SET*/ break; case 1: /*SEEK_CUR*/ bf->l_start += offset; break; case 2: /*SEEK_END*/ bf->l_start += ip->i_d.di_size; break;
Quoted 1 line
should be stripped off as they are not exactly correct.
Sure, they're not _exactly_ the same as seek semantics, but the comment is informative enough to tell you what the magic numbers are supposed to mean as you read the code.
If you really want to strip these out these comments, can you please replace them with a new comment that documents the magic number behaviour?
Cheers,
Dave.
Signature · 3 lines
Dave Chinner Principal Engineer SGI Australian Software Group