Skip to content

Commit e0ee1fd

Browse files
brglChristoph Hellwig
authored andcommitted
samples: configfs: drop unnecessary ternary operators
Checking pointers for NULL value before passing them to container_of() is pointless because even if we return NULL from the ternary operator, none of the users checks the returned value but they instead dereference it unconditionally. AFAICT this cannot really happen either. Simplify the code by removing the ternary operators from to_childless() et al. Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 4472437 commit e0ee1fd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

samples/configfs/configfs_sample.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ struct childless {
3737

3838
static inline struct childless *to_childless(struct config_item *item)
3939
{
40-
return item ? container_of(to_configfs_subsystem(to_config_group(item)),
41-
struct childless, subsys) : NULL;
40+
return container_of(to_configfs_subsystem(to_config_group(item)),
41+
struct childless, subsys);
4242
}
4343

4444
static ssize_t childless_showme_show(struct config_item *item, char *page)
@@ -132,7 +132,7 @@ struct simple_child {
132132

133133
static inline struct simple_child *to_simple_child(struct config_item *item)
134134
{
135-
return item ? container_of(item, struct simple_child, item) : NULL;
135+
return container_of(item, struct simple_child, item);
136136
}
137137

138138
static ssize_t simple_child_storeme_show(struct config_item *item, char *page)
@@ -187,8 +187,8 @@ struct simple_children {
187187

188188
static inline struct simple_children *to_simple_children(struct config_item *item)
189189
{
190-
return item ? container_of(to_config_group(item),
191-
struct simple_children, group) : NULL;
190+
return container_of(to_config_group(item),
191+
struct simple_children, group);
192192
}
193193

194194
static struct config_item *simple_children_make_item(struct config_group *group,

0 commit comments

Comments
 (0)