Module Name: src
Committed By: joerg
Date: Fri Aug 28 09:42:07 UTC 2015
Modified Files:
src/usr.bin/xlint/lint1: scan.l tree.c
Log Message:
~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.
To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.bin/xlint/lint1/scan.l
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/tree.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.60 src/usr.bin/xlint/lint1/scan.l:1.61
--- src/usr.bin/xlint/lint1/scan.l:1.60 Sat Oct 18 08:33:30 2014
+++ src/usr.bin/xlint/lint1/scan.l Fri Aug 28 09:42:07 2015
@@ -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 @@ __RCSID("$NetBSD: scan.l,v 1.60 2014/10/
#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 };
Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.80 src/usr.bin/xlint/lint1/tree.c:1.81
--- src/usr.bin/xlint/lint1/tree.c:1.80 Wed Jul 29 18:23:32 2015
+++ src/usr.bin/xlint/lint1/tree.c Fri Aug 28 09:42:07 2015
@@ -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 @@ chkcomp(op_t op, tnode_t *ln, tnode_t *r
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;