sysprog21 / vsnd

Virtual Linux soundcard driver
MIT License
24 stars 9 forks source link

Check fifo file with the S_ISFIFO macro #6

Closed freshLiver closed 5 months ago

freshLiver commented 5 months ago

There are serveral advantages by using the macro:

  1. hide the bitwise operations by using S_ISFIFO, which has a more informative name, to improve the code readability

  2. make the code more compact, so that the whole expression to check the file type can fit in one line, and there is no need to use the inode pointer, which is not used in other places

  3. the implementation of S_ISFIFO is maintained by the kernel, so it will not affect the module code in case that the kernel changes the name of S_IFIFO or S_IFMT, though it might not be likely to happen

jserv commented 5 months ago

Thank @freshLiver for contributing!