[riot-notifications] [RIOT-OS/RIOT] sys/phydat: added phydat to JSON converter (#7271)

Martine Lenders notifications at github.com
Tue May 19 14:57:12 CEST 2020


@miri64 commented on this pull request.

Minor code-style nit-pick left

> +            }
+            else {
+                pos += (data->val[i]) ? 4 : 5;  /* true: 4, false: 5 */
+            }
+        }
+        pos += strlen(phydat_unit_to_str_verbose(data->unit));
+    }
+    else {
+        memcpy(buf, "{\"d\":", 5);
+        pos += 5;
+        /* write data */
+        if (dim > 1) {
+            buf[pos++] = '[';
+        }
+        for (size_t i = 0; i < dim; i++) {
+            if (data->unit != UNIT_BOOL) {

Nit-pick: reverse logic. It is easier for the brain to parse to handle the `data->unit == UNIT_BOOL` first (the connection to the logical expression to the called function's name is much closer)

-- 
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/7271#pullrequestreview-414414329
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200519/e3c1fcdd/attachment.htm>


More information about the notifications mailing list