Date: Sat, 15 Jan 2005 01:46:41 +0000 (UTC) From: Brooks Davis <brooks@FreeBSD.org> To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/sbin/ipfw ipfw2.c Message-ID: <200501150146.j0F1kfXf026648@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200501150146.j0F1kfXf026648>