@@ -121,10 +121,13 @@ static void *kernfs_seq_start(struct seq_file *sf, loff_t *ppos)
return next;
} else {
/*
- * The same behavior and code as single_open(). Returns
- * !NULL if pos is at the beginning; otherwise, NULL.
+ * The same behavior and code as single_open(). Continues
+ * if pos is at the beginning; otherwise, NULL.
*/
- return NULL + !*ppos;
+ if (*ppos)
+ return NULL;
+
+ return SEQ_OPEN_SINGLE;
}
}
@@ -526,7 +526,10 @@ EXPORT_SYMBOL(seq_dentry);
static void *single_start(struct seq_file *p, loff_t *pos)
{
- return NULL + (*pos == 0);
+ if (*pos)
+ return NULL;
+
+ return SEQ_OPEN_SINGLE;
}
static void *single_next(struct seq_file *p, void *v, loff_t *pos)
@@ -37,6 +37,12 @@ struct seq_operations {
#define SEQ_SKIP 1
+/*
+ * op->start must return a non-NULL pointer for single_open(),
+ * this is used when we don't care about the specific value.
+ */
+#define SEQ_OPEN_SINGLE (void *)1
+
/**
* seq_has_overflowed - check if the buffer has overflowed
* @m: the seq_file handle