[tor-bugs] #31374 [Core Tor/Tor]: Appveyor: cast between incompatible function types in compat_time

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Aug 8 14:46:53 UTC 2019


#31374: Appveyor: cast between incompatible function types in compat_time
-------------------------+-------------------------------------------------
     Reporter:  teor     |      Owner:  (none)
         Type:  defect   |     Status:  new
     Priority:  Medium   |  Milestone:  Tor: 0.4.1.x-final
    Component:  Core     |    Version:  Tor: 0.2.9.1-alpha
  Tor/Tor                |   Keywords:  041-must tor-ci Windows
     Severity:  Normal   |  029-backport 035-backport 040-backport
                         |  041-backport
Actual Points:           |  Parent ID:  #31343
       Points:  0.5      |   Reviewer:
      Sponsor:           |
  Sponsor2-must          |
-------------------------+-------------------------------------------------
 The latest Appveyor compiler complains:
 {{{
 ../src/lib/time/compat_time.c:522:25: error: cast between incompatible
 function types from 'FARPROC' to 'ULONGLONG (__attribute__((stdcall))
 *)(void)' [-Werror=cast-function-type]
   522 |     GetTickCount64_fn = (GetTickCount64_fn_t)
       |                         ^
 }}}

 This issue is like #27465:

 GetProcAddress() returns FARPROC, which is (long long int(*)()) on
 64-bit Windows:
 https://msdn.microsoft.com/en-
 us/library/windows/desktop/ms683212(v=vs.85).aspx

 But GetTickCount64() is (long long unsigned int(*)()), on both 32-bit
 and 64-bit Windows:
 https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-
 sysinfoapi-gettickcount64

 So gcc 8 issues a spurious "incompatible function pointer" warning
 about the cast to GetTickCount64_fn_t.

 Silence this warning by casting to a void function pointer, before
 the cast to GetTickCount64_fn_t.

 Fixes bug NNNNN; bugfix on 0.2.9.1-alpha.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/31374>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list