Project

General

Profile

Bug #6257

Commit 76a6263 breaks compilation

Added by John Hunt over 1 year ago. Updated over 1 year ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
General
Target version:
-
Start date:
2023-03-14
Due date:
% Done:

0%

Estimated time:
Found in version:
4.3-2105~g76a6263f1
Affected Versions:

Description

I couldn't find a bug report for this, so I'm guessing the following patch aims to provide a 64-bit format specifier for time_t on 32-bit systems.

https://github.com/tvheadend/tvheadend/commit/76a6263f1be4e3ccff968b47155b050fcc15f042

The problem is the PRItime_t format specifier is changed on all systems except for 32-bit FreeBSD, even though the description says it's for 32-bit systems. This breaks compilation on several platforms. If I understand correctly, time_t requires an "ld" format specifier on 64-bit systems, but PRId64 expands to "lld" on some 64 bit systems. This generates a format specification error even though 'long int' and 'long long int' are (probably) the same on 64-bit systems. So, you need to cast time_t to work with the PRId64 macro specifier. This is ugly, but should work on both 32 & 64-bit systems.

Something like this in otamux.c?

tvhtrace(LS_EPGGRAB, "next ota start event in %"PRId64" seconds", (__INT64_TYPE__)next - time(NULL));

Furthermore, if the goal was provide a 64-bit format specifier for time_t on 32-bit systems, wouldn't something like the following in tvheadend.h be preferable?
#if __WORDSIZE == 32 && defined(PLATFORM_FREEBSD)
#define PRItime_t       "d" 
#elif  __WORDSIZE == 32
#define PRItime_t       "lld" 
#else
#define PRItime_t       "ld" 
#endif

History

#1

Updated by Flole Systems over 1 year ago

  • Status changed from New to Fixed

Also available in: Atom PDF