<p><b>@smlng</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/RIOT-OS/RIOT/pull/10671#discussion_r245590691">sys/net/application_layer/nanocoap/sock.c</a>:</p>
<pre style='color:#555'>> @@ -46,19 +46,14 @@ ssize_t nanocoap_request(coap_pkt_t *pkt, sock_udp_ep_t *local, sock_udp_ep_t *r
 
     /* TODO: timeout random between between ACK_TIMEOUT and (ACK_TIMEOUT *
      * ACK_RANDOM_FACTOR) */
-    uint32_t timeout = COAP_ACK_TIMEOUT * (1000000U);
-    int tries = 0;
-    while (tries++ < COAP_MAX_RETRANSMIT) {
-        if (!tries) {
-            DEBUG("nanocoap: maximum retries reached.\n");
-            res = -ETIMEDOUT;
-            goto out;
-        }
+    uint32_t timeout = COAP_ACK_TIMEOUT * (1 * US_PER_SEC);
</pre>
<p>I guess you can skip the <code>1 *</code> and simplify to <code>COAP_ACK_TIMEOUT * US_PER_SEC</code>, or not?</p>

<hr>

<p>In <a href="https://github.com/RIOT-OS/RIOT/pull/10671#discussion_r245593355">sys/net/application_layer/nanocoap/sock.c</a>:</p>
<pre style='color:#555'>> @@ -46,19 +46,14 @@ ssize_t nanocoap_request(coap_pkt_t *pkt, sock_udp_ep_t *local, sock_udp_ep_t *r
 
     /* TODO: timeout random between between ACK_TIMEOUT and (ACK_TIMEOUT *
      * ACK_RANDOM_FACTOR) */
-    uint32_t timeout = COAP_ACK_TIMEOUT * (1000000U);
-    int tries = 0;
-    while (tries++ < COAP_MAX_RETRANSMIT) {
-        if (!tries) {
-            DEBUG("nanocoap: maximum retries reached.\n");
-            res = -ETIMEDOUT;
-            goto out;
-        }
+    uint32_t timeout = COAP_ACK_TIMEOUT * (1 * US_PER_SEC);
+    unsigned tries_left = COAP_MAX_RETRANSMIT + 1;  /* add 1 for initial transmit */
+    while (tries_left) {
</pre>
<p>I guess the <em>correct</em> (more C'ish) (?) way would be to use <code>do { ... } while ( ... );</code>, like:</p>
<pre><code>unsigned tries_left = COAP_MAX_RETRANSMIT;
do {
[...]
} while (tries_left--);
</code></pre>
<p>This should also work for <code>COAP_MAX_RETRANSMIT = 0</code>, that is: send once and no retries.<br>
though I also guess this will not impact code size, as the compiler will optimise both the same way.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/10671#pullrequestreview-189728374">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AEn7YPAjHRyQsOGrBeEYJsJmKSc-Kk3Tks5vAxS-gaJpZM4ZjvZp">mute the thread</a>.<img src="https://github.com/notifications/beacon/AEn7YGpmqYDCCyz_EoVGQd_BSZJLntsTks5vAxS-gaJpZM4ZjvZp.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/RIOT-OS/RIOT","title":"RIOT-OS/RIOT","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/RIOT-OS/RIOT"}},"updates":{"snippets":[{"icon":"PERSON","message":"@smlng commented on #10671"}],"action":{"name":"View Pull Request","url":"https://github.com/RIOT-OS/RIOT/pull/10671#pullrequestreview-189728374"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/10671#pullrequestreview-189728374",
"url": "https://github.com/RIOT-OS/RIOT/pull/10671#pullrequestreview-189728374",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>