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

0.21.4: FTBFS with miniupnpc 2.2.8 ("too few arguments to function") [PATCH] #1004

Open
onlyjob opened this issue Jan 29, 2025 · 0 comments
Open

Comments

@onlyjob
Copy link

onlyjob commented Jan 29, 2025

As reported in Debian, Litecoin 0.21.4 FTBFS as follows:

net.cpp: In function ‘void ThreadMapPort()’:
net.cpp:1640:25: error: too few arguments to function ‘int UPNP_GetValidIGD(UPNPDev*, UPNPUrls*, IGDdatas*, char*, int, char*, int)’
 1640 |     r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from net.cpp:40:
/usr/include/miniupnpc/miniupnpc.h:122:1: note: declared here
  122 | UPNP_GetValidIGD(struct UPNPDev * devlist,
      | ^~~~~~~~~~~~~~~~

The following patch (proposed by Gui-Yue [email protected]) fixed the problem:

--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1636,9 +1636,14 @@
     struct UPNPUrls urls;
     struct IGDdatas data;
     int r;
 
-    r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
+    char errorMsg[256];
+    #if MINIUPNPC_API_VERSION >= 18
+        r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr), errorMsg, sizeof(errorMsg));
+    #else
+        r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
+    #endif
     if (r == 1)
     {
         if (fDiscover) {
             char externalIPAddress[40];

My solution to this issue:
According to the error message, the issue lies in the call to the
UPNP_GetValidIGD function, indicating an insufficient number of arguments.
In newer versions, the function signature of UPNP_GetValidIGD has been
updated with additional parameters, such as char *errorMsg and int
errorMsgLen. I resolved the issue by adding the required parameters for the
new version, while also incorporating conditional checks to ensure
compatibility with older versions of miniupnpc.I have tested this solution
locally,and it works well.The debpatch is in the attachment.Please let me
know whether this solution can be accepted.

Gui-Yue
Best regards

@onlyjob onlyjob changed the title 0.21.4: FTBFS ("too few arguments to function") [PATCH] 0.21.4: FTBFS with miniupnpc 2.2.8 ("too few arguments to function") [PATCH] Jan 29, 2025
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

1 participant