[riot-notifications] [RIOT-OS/RIOT] periph/gpio: add gpio_set_cb() function (#12082)

Marian Buschsieweke notifications at github.com
Tue Sep 17 12:27:53 CEST 2019


maribu commented on this pull request.



> @@ -416,6 +416,25 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
     return 0;
 }
 
+int gpio_set_cb(gpio_t pin, gpio_cb_t cb, void *arg)
+{
+    int8_t int_num = _int_num(pin);
+
+    if (int_num < 0) {
+        return -1;
+    }
+
+    if (cb) {
+        config[int_num].cb = cb;
+    }
+
+    if (arg) {
+        config[int_num].arg = arg;
+    }

@benpicco: I'm referring to this. Let's say I want to set `cb` to `foo`, and `arg` to `NULL`. This is not possible, as only for non-`NULL` values of `arg` it is actually updated.

Maybe you intended to write the following instead:

```C
if (cb) {
    config[int_num].cb = cb;
    config[int_num].arg = arg;
}
```
?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/12082#pullrequestreview-289164476
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190917/ed6ac3d9/attachment-0001.htm>


More information about the notifications mailing list