apache / apache/mynewt-nimble

Change Macro from min to MIN in lpn.c

Open
#1,709 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
893
Forks
512
Avg merge
13d 31m
Merged PRs (30d)
7

Description

Hi,
I am using Nimble in ESP-IDF from a C project and GCC complains about undefined function min() (small letters).
MIN() (big letters) is used also in this file and works with C projects as it is defined in indirectly included mesh/glue.h (via mesh/mesh.h).
Please change other occurrences from min to MIN.

---8<---

--- lpn_orig.c 2024-02-14 21:01:16.662505000 +0100
+++ lpn.c 2024-02-22 20:05:41.852456394 +0100
@@ -32,7 +32,7 @@
#endif

#define LPN_RECV_DELAY MYNEWT_VAL(BLE_MESH_LPN_RECV_DELAY)
-#define SCAN_LATENCY min(MYNEWT_VAL(BLE_MESH_LPN_SCAN_LATENCY), \
+#define SCAN_LATENCY MIN(MYNEWT_VAL(BLE_MESH_LPN_SCAN_LATENCY), \
LPN_RECV_DELAY)

#define FRIEND_REQ_RETRY_TIMEOUT K_SECONDS(MYNEWT_VAL(BLE_MESH_LPN_RETRY_TIMEOUT))
@@ -152,12 +152,12 @@
{
/* If we're waiting for segment acks keep polling at high freq */
if (bt_mesh_tx_in_progress()) {
- return min(POLL_TIMEOUT_MAX(lpn), K_SECONDS(1));
+ return MIN(POLL_TIMEOUT_MAX(lpn), K_SECONDS(1));
}

if (lpn->poll_timeout < POLL_TIMEOUT_MAX(lpn)) {
lpn->poll_timeout *= 2;
- lpn->poll_timeout = min(lpn->poll_timeout,
+ lpn->poll_timeout = MIN(lpn->poll_timeout,
POLL_TIMEOUT_MAX(lpn));
}

@@ -1000,7 +1000,7 @@
}

/* Set initial poll timeout */
- lpn->poll_timeout = min(POLL_TIMEOUT_MAX(lpn),
+ lpn->poll_timeout = MIN(POLL_TIMEOUT_MAX(lpn),
POLL_TIMEOUT_INIT);
}

--->8---

Best regards

Contributor guide

No contributing guide indexed for this repository

Research direction

Open lpn.c and inspect the existing MIN usage alongside the lowercase min occurrences identified in the issue. Run the affected GCC build from the ESP-IDF C project, then confirm that lpn.c has no remaining lowercase min calls and the build no longer reports min as undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, networking
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.