Skip to content

Commit

Permalink
Use off_t in for constants used in iprop log seeks
Browse files Browse the repository at this point in the history
On 32-bit architectures with _FILE_OFFSET_BITS=64,
 sizeof(off_t) > sizeof(size_t) .

LOG_HEADER_SZ was #define'd as an expression of type size_t, so in order
to get the sign extension right we need -(off_t)LOG_HEADER_SZ instead of
(off_t)(-LOG_HEADER_SZ).  However, we can just define the *_SZ macros to
cast to off_t, then we don't need to worry about negation.

Fixes Debian bug #822749, PR 175.

Signed-off-by (and updated by): Nicolas Williams <nico@twosigma.com>
  • Loading branch information
Sergio Gelato authored and nicowilliams committed Nov 9, 2016
1 parent 96a31c2 commit 7c8b66d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/kadm5/log.c
Expand Up @@ -174,11 +174,11 @@ RCSID("$Id$");
* will deadlock with ipropd-slave -- don't do that.
*/

#define LOG_HEADER_SZ (sizeof(uint32_t) * 4)
#define LOG_TRAILER_SZ (sizeof(uint32_t) * 2)
#define LOG_WRAPPER_SZ (LOG_HEADER_SZ + LOG_TRAILER_SZ)
#define LOG_UBER_LEN (sizeof(uint64_t) + sizeof(uint32_t) * 2)
#define LOG_UBER_SZ (LOG_WRAPPER_SZ + LOG_UBER_LEN)
#define LOG_HEADER_SZ ((off_t)(sizeof(uint32_t) * 4))
#define LOG_TRAILER_SZ ((off_t)(sizeof(uint32_t) * 2))
#define LOG_WRAPPER_SZ ((off_t)(LOG_HEADER_SZ + LOG_TRAILER_SZ))
#define LOG_UBER_LEN ((off_t)(sizeof(uint64_t) + sizeof(uint32_t) * 2))
#define LOG_UBER_SZ ((off_t)(LOG_WRAPPER_SZ + LOG_UBER_LEN))

#define LOG_NOPEEK 0
#define LOG_DOPEEK 1
Expand Down

0 comments on commit 7c8b66d

Please sign in to comment.