Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler warning issued when MDNS_MAX_SERVICES is 0 (IDFGH-13222) #611

Open
3 tasks done
gudvinr opened this issue Jul 10, 2024 · 1 comment
Open
3 tasks done

Compiler warning issued when MDNS_MAX_SERVICES is 0 (IDFGH-13222) #611

gudvinr opened this issue Jul 10, 2024 · 1 comment
Assignees

Comments

@gudvinr
Copy link

gudvinr commented Jul 10, 2024

Answers checklist.

  • I have read the documentation for esp-protocols components and the issue is not addressed there.
  • I have updated my esp-protocols branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

What component are you using? If you choose Other, provide details in More Information.

mDNS

component version

1.3.2

IDF version.

5.2.2

More Information.

There's a check in mdns.c:340 that uses MDNS_MAX_SERVICES value in runtime.

If it's set to 0 (when you only need domain resolution and not DNS-SD), you get a warning:
comparison is always true due to limited range of data type [-Wtype-limits]

Instead _mdns_can_add_more_services can return false straight away if MDNS_MAX_SERVICES defined as 0.

@github-actions github-actions bot changed the title Compiler warning issued when MDNS_MAX_SERVICES is 0 Compiler warning issued when MDNS_MAX_SERVICES is 0 (IDFGH-13222) Jul 10, 2024
@david-cermak
Copy link
Collaborator

Thanks for reporting this issue!

Instead _mdns_can_add_more_services can return false straight away if MDNS_MAX_SERVICES defined as 0.

Good idea! Feel free to post a PR with this change.

Alternatively we can use const size_t instead of macros:

 static bool _mdns_can_add_more_services(void)
 {
+    const int max_services = CONFIG_MDNS_MAX_SERVICES;
     mdns_srv_item_t *s = _mdns_server->services;
     uint16_t service_num = 0;
     while (s) {
         service_num ++;
         s = s->next;
-        if (service_num >= MDNS_MAX_SERVICES) {
+        if (service_num >= max_services) {
             return false;
         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants