get rid of unused variables
[project/uqmi.git] / dev.c
diff --git a/dev.c b/dev.c
index 21e30ea..2e20274 100644 (file)
--- a/dev.c
+++ b/dev.c
@@ -7,6 +7,8 @@
 #include "qmi-errors.h"
 #include "qmi-errors.c"
 
+bool cancel_all_requests = false;
+
 #define __qmi_service(_n) [__##_n] = _n
 static const uint8_t qmi_services[__QMI_SERVICE_LAST] = {
        __qmi_services
@@ -47,7 +49,6 @@ static void __qmi_request_complete(struct qmi_dev *qmi, struct qmi_request *req,
 {
        void *tlv_buf;
        int tlv_len;
-       int ret;
 
        if (!req->pending)
                return;
@@ -55,10 +56,14 @@ static void __qmi_request_complete(struct qmi_dev *qmi, struct qmi_request *req,
        req->pending = false;
        list_del(&req->list);
 
-       tlv_buf = qmi_msg_get_tlv_buf(msg, &tlv_len);
-       req->ret = qmi_check_message_status(tlv_buf, tlv_len);
-       if (req->ret)
-               msg = NULL;
+       if (msg) {
+               tlv_buf = qmi_msg_get_tlv_buf(msg, &tlv_len);
+               req->ret = qmi_check_message_status(tlv_buf, tlv_len);
+               if (req->ret)
+                       msg = NULL;
+       } else {
+               req->ret = QMI_ERROR_CANCELLED;
+       }
 
        if (req->cb && (msg || !req->no_error_cb))
                req->cb(qmi, req, msg);
@@ -97,7 +102,6 @@ static void qmi_notify_read(struct ustream *us, int bytes)
        struct qmi_msg *msg;
        char *buf;
        int len, msg_len;
-       int i;
 
        while (1) {
                buf = ustream_get_read_buf(us, &len);
@@ -122,8 +126,6 @@ int qmi_request_start(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_m
 {
        int len = qmi_complete_request_message(msg);
        uint16_t tid;
-       int ret;
-       int i;
 
        memset(req, 0, sizeof(*req));
        req->ret = -1;
@@ -174,6 +176,10 @@ int qmi_request_wait(struct qmi_dev *qmi, struct qmi_request *req)
                cancelled = uloop_cancelled;
                uloop_cancelled = false;
                uloop_run();
+
+               if (cancel_all_requests)
+                       qmi_request_cancel(qmi, req);
+
                uloop_cancelled = cancelled;
        }
 
@@ -304,7 +310,6 @@ int qmi_device_open(struct qmi_dev *qmi, const char *path)
 void qmi_device_close(struct qmi_dev *qmi)
 {
        struct qmi_request *req;
-       int idx;
 
        qmi_close_all_services(qmi);
        ustream_free(&qmi->sf.stream);