- 如果函数里里while操作去读寄存器,一定要加上timeout
- 如果出现error,最好是return, 不要继续执行了。
而且return最好是按照linux的标准返回error。注意返回的时候在这些macro前要加上负号。
define EPERM 1 /* Operation not permitted */
define ENOENT 2 /* No such file or directory */
define ESRCH 3 /* No such process */
define EINTR 4 /* Interrupted system call */
define EIO 5 /* I/O error */
define ENXIO 6 /* No such device or address */
define E2BIG 7 /* Argument list too long */
define ENOEXEC 8 /* Exec format error */
define EBADF 9 /* Bad file number */
- 函数最好不要return 0, -1 ,-2, 做好按照linux 的标准
- 函数尽量加返回值,尽量不用void
5.声明的枚举变量前面加上e_,结构体变量加s_。 举一反三。
6判断是否是16的倍数,不要用%16, 可以用&15 来判断。