diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c
index 1dfc6fd6437d60c647e271ed0e7c75a19ca1a170..be30dc64fb4ebb6b37da6695f96dc1026dc8809b 100644
--- a/sys/net/application_layer/gcoap/gcoap.c
+++ b/sys/net/application_layer/gcoap/gcoap.c
@@ -827,7 +827,7 @@ int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf)
                 if ((pos + path_len + 3) > maxlen) {
                     break;
                 }
-                if (i) {
+                if (pos) {
                     out[pos++] = ',';
                 }
                 out[pos++] = '<';
@@ -836,7 +836,7 @@ int gcoap_get_resource_list(void *buf, size_t maxlen, uint8_t cf)
                 out[pos++] = '>';
             }
             else {
-                pos += (i) ? 3 : 2;
+                pos += (pos) ? 3 : 2;
                 pos += path_len;
             }
             ++resource;