mirror of
https://github.com/sysprog21/lkmpg.git
synced 2024-11-22 15:46:59 +08:00
470fbcd97d
The code 'case -EINPROGRESS || -EBUSY: ' is the same as 'case -115 || -16 :' at compiler time, as both error code are implemented with macro like '#define EBUSY 16'. The code above is essentially the same as 'case 1:'. In C, there is no real boolean value. Boolean-like value will be converted to 1 or 0. It does not matter too much if the '-EINPROGRESS || -EBUSY' is calculated at build time or at runtime. In both case, it will compare the 'rc' with 1 in the switch expression. It will not compare the 'rc' with any real error code number. When the code is really '-EBUSY', the execution will fallback to the default branch. And in practice, most of the compilers will do this simple compile-time static calculation, and generate code like static int test_skcipher_result(struct skcipher_def *sk, int rc) { switch (rc) { case 0: break; case 1: rc = wait_for_completion_interruptible(&sk->result.completion); /* code removed for conciseness */ break; default: pr_info("skcipher encrypt returned with %d result %d\n", rc, sk->result.err); break; } init_completion(&sk->result.completion); return rc; } |
||
---|---|---|
.. | ||
other | ||
.clang-format | ||
bottomhalf.c | ||
chardev.c | ||
chardev.h | ||
chardev2.c | ||
completions.c | ||
cryptosha256.c | ||
cryptosk.c | ||
devicemodel.c | ||
example_atomic.c | ||
example_mutex.c | ||
example_rwlock.c | ||
example_spinlock.c | ||
example_tasklet.c | ||
hello-1.c | ||
hello-2.c | ||
hello-3.c | ||
hello-4.c | ||
hello-5.c | ||
hello-sysfs.c | ||
intrpt.c | ||
ioctl.c | ||
kbleds.c | ||
Makefile | ||
print_string.c | ||
procfs1.c | ||
procfs2.c | ||
procfs3.c | ||
procfs4.c | ||
sched.c | ||
sleep.c | ||
start.c | ||
static_key.c | ||
stop.c | ||
syscall-steal.c | ||
vinput.c | ||
vinput.h | ||
vkbd.c |