Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 ~0 and -1 are the same for two-complemen...
details: https://anonhg.NetBSD.org/src/rev/4b7e5534f64f
branches: trunk
changeset: 340230:4b7e5534f64f
user: joerg <joerg%NetBSD.org@localhost>
date: Fri Aug 28 09:42:07 2015 +0000
description:
~0 and -1 are the same for two-complement machines. ISO C says left
shifts of negative values are UB, so do the shift for the unsigned
equivalent and cast to int afterwards.
diffstat:
usr.bin/xlint/lint1/scan.l | 6 +++---
usr.bin/xlint/lint1/tree.c | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diffs (63 lines):
diff -r 74a6c117dbe1 -r 4b7e5534f64f usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l Fri Aug 28 09:30:01 2015 +0000
+++ b/usr.bin/xlint/lint1/scan.l Fri Aug 28 09:42:07 2015 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.60 2014/10/18 08:33:30 snj Exp $ */
+/* $NetBSD: scan.l,v 1.61 2015/08/28 09:42:07 joerg Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.60 2014/10/18 08:33:30 snj Exp $");
+__RCSID("$NetBSD: scan.l,v 1.61 2015/08/28 09:42:07 joerg Exp $");
#endif
#include <stdlib.h>
@@ -49,7 +49,7 @@
#include "lint1.h"
#include "cgram.h"
-#define CHAR_MASK (~(~0 << CHAR_BIT))
+#define CHAR_MASK ((int)(~(~0U << CHAR_BIT)))
/* Current position (its also updated when an included file is parsed) */
pos_t curr_pos = { 1, "", 0 };
diff -r 74a6c117dbe1 -r 4b7e5534f64f usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Fri Aug 28 09:30:01 2015 +0000
+++ b/usr.bin/xlint/lint1/tree.c Fri Aug 28 09:42:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.80 2015/07/29 18:23:32 christos Exp $ */
+/* $NetBSD: tree.c,v 1.81 2015/08/28 09:42:07 joerg Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.80 2015/07/29 18:23:32 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.81 2015/08/28 09:42:07 joerg Exp $");
#endif
#include <stdlib.h>
@@ -3795,14 +3795,14 @@
if ((hflag || pflag) && lt == CHAR && rn->tn_op == CON &&
(rn->tn_val->v_quad < 0 ||
- rn->tn_val->v_quad > ~(~0 << (CHAR_BIT - 1)))) {
+ rn->tn_val->v_quad > (int)~(~0U << (CHAR_BIT - 1)))) {
/* nonportable character comparison, op %s */
warning(230, mp->m_name);
return;
}
if ((hflag || pflag) && rt == CHAR && ln->tn_op == CON &&
(ln->tn_val->v_quad < 0 ||
- ln->tn_val->v_quad > ~(~0 << (CHAR_BIT - 1)))) {
+ ln->tn_val->v_quad > (int)~(~0U << (CHAR_BIT - 1)))) {
/* nonportable character comparison, op %s */
warning(230, mp->m_name);
return;
Home |
Main Index |
Thread Index |
Old Index