linux kernel - why it is not wise to check -ENODEV for debugfs api -


debugfs api such debugfs_create_dir said

if debugfs not enabled in kernel, value -enodev returned. not wise check value, rather, check null or !null instead eliminate need #ifdef in calling code.

but why not wise? give me examples eliminate need #ifdef in calling code?

one may interpret -enodev success, until doing dentry returned except deleting it(debugfs_remove) , using directory file(debugfs_create_-family). these functions process case, when config_debug_fs disabled, correctly.

that's why sufficient check null or !null.

in rare cases, when dentry returned debugfs_create_*() referred explicitely(e.g, access inode's private data), sufficient check, first such call doesn't return -enodev.


Comments