lkml.org 
[lkml]   [2006]   [May]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 3/3] openpromfs: factorize out

"Move" "common code" out to PTR_NOD, which does the conversion from private
pointer to node number. This is to reduce potential casting/conversion
errors due to redundancy. (The naming PTR_NOD follows PTR_ERR, turning a
pointer into xyz.)

Signed-off-by: Jan Engelhardt <jengelh@gmx.de>

diff --fast -Ndpru linux-2.6.17-rc4~/fs/openpromfs/inode.c linux-2.6.17-rc4+/fs/openpromfs/inode.c
--- linux-2.6.17-rc4~/fs/openpromfs/inode.c 2006-05-16 21:00:09.445807000 +0200
+++ linux-2.6.17-rc4+/fs/openpromfs/inode.c 2006-05-16 20:59:53.845807000 +0200
@@ -64,6 +64,10 @@ static int openpromfs_readdir(struct fil
static struct dentry *openpromfs_lookup(struct inode *, struct dentry *dentry, struct nameidata *nd);
static int openpromfs_unlink (struct inode *, struct dentry *dentry);

+static inline u16 PTR_NOD(void *p) {
+ return (long)p & 0xFFFF;
+}
+
static ssize_t nodenum_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{
@@ -95,9 +99,9 @@ static ssize_t property_read(struct file
char buffer[64];

if (!filp->private_data) {
- node = nodes[(u16)((long)inode->u.generic_ip)].node;
+ node = nodes[PTR_NOD(inode->u.generic_ip)].node;
i = ((u32)(long)inode->u.generic_ip) >> 16;
- if ((u16)((long)inode->u.generic_ip) == aliases) {
+ if (PTR_NOD(inode->u.generic_ip) == aliases) {
if (i >= aliases_nodes)
p = NULL;
else
@@ -111,7 +115,7 @@ static ssize_t property_read(struct file
return -EIO;
i = prom_getproplen (node, p);
if (i < 0) {
- if ((u16)((long)inode->u.generic_ip) == aliases)
+ if (PTR_NOD(inode->u.generic_ip) == aliases)
i = 0;
else
return -EIO;
@@ -540,8 +544,8 @@ int property_release (struct inode *inod
if (!op)
return 0;
lock_kernel();
- node = nodes[(u16)((long)inode->u.generic_ip)].node;
- if ((u16)((long)inode->u.generic_ip) == aliases) {
+ node = nodes[PTR_NOD(inode->u.generic_ip)].node;
+ if (PTR_NOD(inode->u.generic_ip) == aliases) {
if ((op->flag & OPP_DIRTY) && (op->flag & OPP_STRING)) {
char *p = op->name;
int i = (op->value - op->name) - strlen (op->name) - 1;
#<<eof>>
Jan Engelhardt
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-05-16 21:23    [W:1.233 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site