Cast argument to uint64_t first before shifting to avoid UB for

left-shifting negative values.
This commit is contained in:
joerg 2015-11-23 23:45:44 +00:00
parent 94e1cb8831
commit b735893a87
1 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ntptime.c,v 1.56 2015/07/24 13:02:52 maxv Exp $ */
/* $NetBSD: kern_ntptime.c,v 1.57 2015/11/23 23:45:44 joerg Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -60,7 +60,7 @@
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.59 2005/05/28 14:34:41 rwatson Exp $"); */
__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.56 2015/07/24 13:02:52 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.57 2015/11/23 23:45:44 joerg Exp $");
#ifdef _KERNEL_OPT
#include "opt_ntp.h"
@ -99,7 +99,7 @@ typedef int64_t l_fp;
#define L_MPY(v, a) ((v) *= (a))
#define L_CLR(v) ((v) = 0)
#define L_ISNEG(v) ((v) < 0)
#define L_LINT(v, a) ((v) = (int64_t)(a) << 32)
#define L_LINT(v, a) ((v) = (int64_t)((uint64_t)(a) << 32))
#define L_GINT(v) ((v) < 0 ? -(-(v) >> 32) : (v) >> 32)
#ifdef NTP