This object function is static,
static function if no other access to the function, then
at the compile time, unused error will occur,
can be added before the function attribute ((unused)) to avoid unused error,
but if the real function of the body when there is for error, will be detected.
Case 1
function not being accessed
1335 static irqreturn_t xxx_handler(int irq, void *data) 1336 { 1337 struct smbchg_chip *chip = (struct smbchg_chip *)data; ..... .....
..... ..... android/kernel/msm-3.18/drivers/power/qpnp-smbcharger.c:1335:20: warning: 'xxx_handler' defined but not used [-Wunused-function] error, forbidden warning: qpnp-smbcharger.c:1335 make[3]: *** [drivers/power/qpnp-smbcharger.o] Error 1 make[2]: *** [drivers/power] Error 2 make[1]: *** [drivers] Error 2 make[1]: *** Waiting for unfinished jobs.... ..... ..... .....
Case 2
function has not been accessed and adding attribute ((unused))
1335 __attribute__((unused)) static irqreturn_t xxx_handler(int irq, void *data) 1336 { 1337 struct smbchg_chip *chip = (struct smbchg_chip *)data; ..... ..... .....
compile success
Case 3
function has not been accessed and adding attribute ((unused)) and the error function has a body
1335 static _attribute__((unused)) irqreturn_t xxx_handler(int irq, void *data) 1336 { 1337 asfadsf 1338 struct smbchg_chip *chip = (struct smbchg_chip *)data; ..... ..... .....
..... ..... android/kernel/msm-3.18/drivers/power/qpnp-smbcharger.c:1337:9: error: 'asfadsf' undeclared (first use in this function) asfadsf ^ ..... .....
The timing of the application
When the coder is still under implementation function of the body, and want to check whether there is an error, you can use
Transfer: https://www.cnblogs.com/youchihwang/p/8986370.html