Opened 3 weeks ago

Closed 3 weeks ago

#27465 closed defect (fixed)

Windows: cast between incompatible function types in address.c

Reported by: teor Owned by: teor
Priority: Medium Milestone: Tor: 0.3.4.x-final
Component: Core Tor/Tor Version: Tor: 0.2.3.11-alpha
Severity: Normal Keywords: 034-must, 034-backport, 033-backport, 032-backport, 029-backport
Cc: mikeperry Actual Points:
Parent ID: #27389 Points:
Reviewer: Sponsor:

Description

bash.exe : ../src/common/address.c: In function 'get_interface_addresses_win32':
At line:2 char:5
+     & $commandPath $args 2>&1
+     ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (../src/common/a...dresses_win32'::String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
../src/common/address.c:1499:14: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'ULONG (*)(ULONG,  ULONG,  void *, IP_ADAPTER_ADDRESSES_XP *, ULONG *)' {aka 'long unsigned int 
(*)(long unsigned int,  long unsigned int,  void *, struct _IP_ADAPTER_ADDRESSES_XP *, long unsigned int *)'} [-Werror=cast-function-type]
   if (!(fn = (GetAdaptersAddresses_fn_t)
              ^

https://ci.appveyor.com/project/teor2345/tor/build/1.0.152/job/g7dxnnck0r3p66n9#L1093

Child Tickets

Change History (7)

comment:1 Changed 3 weeks ago by teor

Status: assignedneeds_information

This has bitten a lot of other projects. They used a void function pointer cast to silence the error:
https://github.com/official-stockfish/Stockfish/issues/1619
https://github.com/syzygy1/Cfish/issues/63
http://emacs.1067599.n8.nabble.com/New-warnings-on-emacs-26-branch-with-gcc-8-2-0-td462323.html

In this particular case, we already got rid of the cast in 0.3.5. So we could backport that patch instead of adding another cast. (GetAdaptersAddresses and GetProcAddress are only supported on Windows XP, so our code won't work on earlier versions anyway.)

comment:2 Changed 3 weeks ago by teor

We could backport this commit, but we'd have to backport to 0.2.9 and later:
https://github.com/torproject/tor/commit/3930416dec02f801ee9c0e1d99fd782c414ffef0

comment:3 Changed 3 weeks ago by nickm

We talked about this on #tor-dev -- casting through void(*)() is probably the answer.

comment:4 Changed 3 weeks ago by teor

Status: needs_informationneeds_revision

My address-cast branch has this fix, but no changes file.

comment:5 Changed 3 weeks ago by teor

Keywords: 033-backport 032-backport 029-backport added; 035-must removed
Status: needs_revisionneeds_review
Version: Tor: 0.3.4.1-alphaTor: 0.2.3.11-alpha

Please see my branch bug27465-029 on https://github.com/teor2345/tor.git

We already fixed this issue in 0.3.5 by removing the lookup and cast in #26481. So the code will conflict when merging to 0.3.5, we should do an --ours merge (and delete the changes file?).

comment:7 Changed 3 weeks ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Merged to 0.2.9 and forward; the 0.3.5 merge was a no-op as noted above.

Note: See TracTickets for help on using tickets.