From owner-svn-src-head@FreeBSD.ORG Sat Feb 16 12:48:06 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DCD4EC86; Sat, 16 Feb 2013 12:48:06 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CB460948; Sat, 16 Feb 2013 12:48:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1GCm6jQ083679; Sat, 16 Feb 2013 12:48:06 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1GCm6Ro083677; Sat, 16 Feb 2013 12:48:06 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201302161248.r1GCm6Ro083677@svn.freebsd.org> From: Dimitry Andric Date: Sat, 16 Feb 2013 12:48:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246874 - in head/contrib/nvi: ex vi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Feb 2013 12:48:06 -0000 Author: dim Date: Sat Feb 16 12:48:06 2013 New Revision: 246874 URL: http://svnweb.freebsd.org/changeset/base/246874 Log: Fix two instances of undefined behaviour in contrib/nvi. Found by: clang ToT Obtained from: NetBSD Reviewed by: jh MFC after: 3 days Modified: head/contrib/nvi/ex/ex_txt.c head/contrib/nvi/vi/v_txt.c Modified: head/contrib/nvi/ex/ex_txt.c ============================================================================== --- head/contrib/nvi/ex/ex_txt.c Sat Feb 16 12:45:57 2013 (r246873) +++ head/contrib/nvi/ex/ex_txt.c Sat Feb 16 12:48:06 2013 (r246874) @@ -398,8 +398,8 @@ txt_dent(sp, tp) ++scno; /* Get the previous shiftwidth column. */ - cno = scno; - scno -= --scno % sw; + cno = scno--; + scno -= scno % sw; /* * Since we don't know what comes before the character(s) being Modified: head/contrib/nvi/vi/v_txt.c ============================================================================== --- head/contrib/nvi/vi/v_txt.c Sat Feb 16 12:45:57 2013 (r246873) +++ head/contrib/nvi/vi/v_txt.c Sat Feb 16 12:48:06 2013 (r246874) @@ -1956,8 +1956,10 @@ txt_dent(sp, tp, isindent) target = current; if (isindent) target += COL_OFF(target, sw); - else - target -= --target % sw; + else { + --target; + target -= target % sw; + } /* * The AI characters will be turned into overwrite characters if the