"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
gotd: drop unneeded strlen() in refname_is_valid()
To:
gameoftrees@openbsd.org
Date:
Wed, 14 Jun 2023 11:11:28 +0200

Download raw body.

Thread
continuing my quest...  it's the only instance of a strlen() +
strncmp() I found.  ok?

diff 1b3d8a5b5982733afad8b2f50c83eea50cac0531 2d0659fbf9dfec7cdbf5c73b663063f477bf790b
commit - 1b3d8a5b5982733afad8b2f50c83eea50cac0531
commit + 2d0659fbf9dfec7cdbf5c73b663063f477bf790b
blob - 8ebf4b83dbc2a957e8463aa6ad76e0f721af95dd
blob + a3860760379f26a53fcf3788e84f9efb36efbdd3
--- gotd/parse.y
+++ gotd/parse.y
@@ -916,7 +916,7 @@ refname_is_valid(char *refname)
 static int
 refname_is_valid(char *refname)
 {
-	if (strlen(refname) < 5 || strncmp(refname, "refs/", 5) != 0) {
+	if (strncmp(refname, "refs/", 5) != 0) {
 		yyerror("reference name must begin with \"refs/\": %s",
 		    refname);
 		return 0;