Skip to content

Commit

Permalink
Fixes libupnp API breakage
Browse files Browse the repository at this point in the history
Fixes github issue #213: Problem compiling with libupnp 1.14.0

UpnpInit() has long been deprecated and has been dropped in 1.14.0.

Use UpnpInit2() instead.
  • Loading branch information
mrjimenez committed Aug 25, 2020
1 parent 004879a commit 8784480
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions docs/Changelog
Expand Up @@ -33,6 +33,9 @@ Version 2.3.3 - The "what do you want?" version.
* Fix sharing directories with non-ASCII names with aMule daemon
* Fix potential invalid detection for empty wxCharBuffer

Phoenix:
* Fixed libupnp API breakage.

scow:
* Fixed compilation with upnp-1.8
* C++11 fixes
Expand Down
10 changes: 4 additions & 6 deletions src/UPnPBase.cpp
Expand Up @@ -826,15 +826,13 @@ m_WanService(NULL)

// Start UPnP
int ret;
char *ipAddress = NULL;
unsigned short port = 0;
ret = UpnpInit(ipAddress, udpPort);
ret = UpnpInit2(0, udpPort);
if (ret != UPNP_E_SUCCESS) {
msg << "error(UpnpInit): Error code ";
msg << "error(UpnpInit2): Error code ";
goto error;
}
port = UpnpGetServerPort();
ipAddress = UpnpGetServerIpAddress();
unsigned short port = UpnpGetServerPort();
char *ipAddress = UpnpGetServerIpAddress();
msg << "bound to " << ipAddress << ":" <<
port << ".";
AddDebugLogLineN(logUPnP, msg);
Expand Down

4 comments on commit 8784480

@sc0w
Copy link
Member

@sc0w sc0w commented on 8784480 Aug 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build fails:

UPnPBase.cpp: In constructor ‘CUPnPControlPoint::CUPnPControlPoint(short unsigned int)’:
UPnPBase.cpp:880:1: error: jump to label ‘error’ [-fpermissive]
 error:
 ^~~~~
UPnPBase.cpp:832:8: note:   from here
   goto error;
        ^~~~~
UPnPBase.cpp:835:8: note:   crosses initialization of ‘char* ipAddress’
  char *ipAddress = UpnpGetServerIpAddress();
        ^~~~~~~~~
UPnPBase.cpp:834:17: note:   crosses initialization of ‘short unsigned int port’
  unsigned short port = UpnpGetServerPort();
                 ^~~~
make[3]: *** [libmuleappcore_a-UPnPBase.o] Error 1
Makefile:1958: recipe for target 'libmuleappcore_a-UPnPBase.o' failed
make[3]: Leaving directory '/home/runner/work/amule/amule/src'
make[2]: *** [all-recursive] Error 1
Makefile:4946: recipe for target 'all-recursive' failed
make[2]: Leaving directory '/home/runner/work/amule/amule/src'
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Makefile:628: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/home/runner/work/amule/amule'
Makefile:522: recipe for target 'all' failed
##[error]Process completed with exit code 2.

https://github.com/amule-project/amule/runs/1028728927

@mrjimenez
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiled ok here with gcc 10, at least I thought so.

Anyway, I'll fix it.

@PhobosK
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me with GCC 9.3.0 the patch works perfectly well and amule master compiles and installs OK...

The build fails:

UPnPBase.cpp: In constructor ‘CUPnPControlPoint::CUPnPControlPoint(short unsigned int)’:
UPnPBase.cpp:880:1: error: jump to label ‘error’ [-fpermissive]
 error:
 ^~~~~
UPnPBase.cpp:832:8: note:   from here
   goto error;
        ^~~~~
UPnPBase.cpp:835:8: note:   crosses initialization of ‘char* ipAddress’
  char *ipAddress = UpnpGetServerIpAddress();
        ^~~~~~~~~
UPnPBase.cpp:834:17: note:   crosses initialization of ‘short unsigned int port’
  unsigned short port = UpnpGetServerPort();
                 ^~~~
make[3]: *** [libmuleappcore_a-UPnPBase.o] Error 1
Makefile:1958: recipe for target 'libmuleappcore_a-UPnPBase.o' failed
make[3]: Leaving directory '/home/runner/work/amule/amule/src'
make[2]: *** [all-recursive] Error 1
Makefile:4946: recipe for target 'all-recursive' failed
make[2]: Leaving directory '/home/runner/work/amule/amule/src'
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Makefile:628: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/home/runner/work/amule/amule'
Makefile:522: recipe for target 'all' failed
##[error]Process completed with exit code 2.

https://github.com/amule-project/amule/runs/1028728927

And isn't the error cited above done with libupnp version 1.6.24? ->
checking for libupnp version >= 1.6.6... yes (version 1.6.24)

@mrjimenez
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi PhobosK,

UpnpInit() was already deprecated in the 1.6.x branch of libupnp, so there was already UpnpInit2() in that version of the library. There should be no problem with that.

Please sign in to comment.