5.请指出下面代码的错误 int handle_message(int message_id) { int result = 0; switch (message_id) { case MSG_ ID_NOTIFY: route_to_notify_thread (message_id); break; case MSG_ID_SHUTDOWN: case MSG_ID_REBOOT: LOGI("System Message %d =====\n", message_id) send_msg_to_sys_thread(message_id); break; default: LOGE ("===== Kaka Wrone Message %d =======\n", message_id) break; } return result;
时间: 2023-08-30 13:04:05 浏览: 79
Android Build.VERSION.SDK_INT
下面代码的错误是在两个case语句中缺少了break语句,导致程序会继续执行下一个case语句的代码。正确的代码如下:
```
int handle_message(int message_id) {
int result = 0;
switch (message_id) {
case MSG_ID_NOTIFY:
route_to_notify_thread(message_id);
break;
case MSG_ID_SHUTDOWN:
case MSG_ID_REBOOT:
LOGI("System Message %d =====\n", message_id);
send_msg_to_sys_thread(message_id);
break;
default:
LOGE("===== Kaka Wrone Message %d =======\n", message_id);
break;
}
return result;
}
```
阅读全文