From owner-cvs-src@FreeBSD.ORG Sat Jan 15 01:46:41 2005 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D2C3B16A4CE; Sat, 15 Jan 2005 01:46:41 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id BB33C43D45; Sat, 15 Jan 2005 01:46:41 +0000 (GMT) (envelope-from brooks@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j0F1kfl6026649; Sat, 15 Jan 2005 01:46:41 GMT (envelope-from brooks@repoman.freebsd.org) Received: (from brooks@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j0F1kfXf026648; Sat, 15 Jan 2005 01:46:41 GMT (envelope-from brooks) Message-Id: <200501150146.j0F1kfXf026648@repoman.freebsd.org> From: Brooks Davis Date: Sat, 15 Jan 2005 01:46:41 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sbin/ipfw ipfw2.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2005 01:46:42 -0000 brooks 2005-01-15 01:46:41 UTC FreeBSD src repository Modified files: sbin/ipfw ipfw2.c Log: Deprecate unmaintainable uses of strncmp to implement abbreviations. This commit replaces those with two new functions that simplify the code and produce warnings that the syntax is deprecated. A small number of sensible abbreviations may be explicitly added based on user feedback. There were previously three types of strncmp use in ipfw: - Most commonly, strncmp(av, "string", sizeof(av)) was used to allow av to match string or any shortened form of it. I have replaced this with a new function _substrcmp(av, "string") which returns 0 if av is a substring of "string", but emits a warning if av is not exactly "string". - The next type was two instances of strncmp(av, "by", 2) which allowed the abbreviation of bytes to "by", "byt", etc. Unfortunately, it also supported "bykHUygh&*g&*7*ui". I added a second new function _substrcmp2(av, "by", "bytes") which acts like the strncmp did, but complains if the user doesn't spell out the word "bytes". - There is also one correct use of strncmp to match "table(" which might have another token after it without a space. Since I changed all the lines anyway, I also fixed the treatment of strncmp's return as a boolean in many cases. I also modified a few strcmp cases as well to be fully consistent. Revision Changes Path 1.67 +112 -60 src/sbin/ipfw/ipfw2.c