From patchwork Mon Nov 20 11:11:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3454 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:50e4:b0:f2:62eb:61c1 with SMTP id r4csp2191877dyd; Mon, 20 Nov 2023 03:12:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvru7gsLtxN9+9gmyguNjiQh159twtm0yxcIHq4Qa9f4yPbuCX+eJfRGS+3YCf2m1ug9W+ X-Received: by 2002:a05:6a00:301d:b0:6c4:dbb5:a340 with SMTP id ay29-20020a056a00301d00b006c4dbb5a340mr8235019pfb.3.1700478731879; Mon, 20 Nov 2023 03:12:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700478731; cv=none; d=google.com; s=arc-20160816; b=jOE41U8MYDaTj8GglvsD0UOuoaQsupou87VPSy5wrqiLDyw+RLuZghSqmtiRFdr67G Z+aSUjv2SwvWGTM0BV4wEy1oLqkeRwxBXH5G855es9IdwSY0+nWAjeGZDHjjqno2BnnA 0GAK1oy2UuJhbhP1Q/7RnDGjNhEUihPyPlrS59n8cGG0OEmHIi9wYAiLXprRFrp2sKx7 C08TqiW9FH0+zpuKKCu6MieepwNnId+nQMU/h0ErMqYmo8t8rlgZHhAPjB2bRT3otfSu JmFO+LIq+xwmTd5zeJ3HTPRykdtKAVxGGH7lLqGs+MIh6e+7W5BCfrLI4CA2CIY0qxEG aY0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=sf8io5YO5PkHssDPx63uZY6cJQ9UcgwMTtKp2gmM54c=; fh=lm0MLPW7DntlrDqRECIiC9JlE1uPxhepE0URYHIf+eE=; b=ETYtgFpnZRA8ZnMRao8iOx6D2cGhWP0VaKRmvfyqOPSCrHl2LhWDZymWXDsvnE47hZ RrijGtXgSbB5oZhVlyWgBQ3PDqFAmua7zKtkuP4ymJIU0pIydpKFWj7sL5xkTFFriveL IqRiYFb8hm96dyjk9/p+9qOpcdJ8SqaAKLC5ULbW+y+ayO4PCxG4IT9L7hTLEg2bBMaO Bbw8IjSTQqOMHkO6ERDv5uVbowu5g7xZb2Ltni10qguMTyq6qPrCE3v5R0FA5pfGVKGd zt5/XMnGdaxWWBdHPLdWBeX9ATAjd0la/IHg2KGUQJBcuv3PQTP/ST4vDCAKX6JPAoRU mubA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=KwvcMLwx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=F75xDcKm; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=PcnK8Rln; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id s26-20020a056a00179a00b006cb88a16f29si2602913pfg.161.2023.11.20.03.12.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2023 03:12:11 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=KwvcMLwx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=F75xDcKm; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=PcnK8Rln; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r52Bo-0007tP-2Z; Mon, 20 Nov 2023 11:11:40 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r52Bl-0007st-5q for openvpn-devel@lists.sourceforge.net; Mon, 20 Nov 2023 11:11:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6drtkgiEQeLI8ZZiBr8mtZ0Rl4GAMb/OR3BlfwpnCds=; b=KwvcMLwxj65+6z9i5OD2hJTVjt 917Kx39QV6/2SB7gSNDbs8+vdF55bF21MbsGkPHgphejVSTDK+jRGAXIjw4PH/8V2y3pp16nuei// BG5HiQBCG37k1oBv9DUN+kDyTJ7j4RTa4JNygd4J28LaaUfV6AJU1cQySoH7LXJ2cse8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=6drtkgiEQeLI8ZZiBr8mtZ0Rl4GAMb/OR3BlfwpnCds=; b=F 75xDcKmiXIIbjM8rL3mWB/f1du2hAecDFUFDYro1jwEjc/RXsAZL7ZCdeqq5Kz+FWNtmWgAGcGZr/ D5FTqztOV0M5/d/KlsnjnBDty7l7WlA8jFI1+duaeUAqn9q7Ba6/BUP4d9ICh3OxmLWkM4iGcV3DK 0IBu7CukwZesnUBc=; Received: from mail-lf1-f50.google.com ([209.85.167.50]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1r52Bc-00Awqm-2v for openvpn-devel@lists.sourceforge.net; Mon, 20 Nov 2023 11:11:37 +0000 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5094727fa67so5859547e87.3 for ; Mon, 20 Nov 2023 03:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1700478681; x=1701083481; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=6drtkgiEQeLI8ZZiBr8mtZ0Rl4GAMb/OR3BlfwpnCds=; b=PcnK8RlnLKTY41IvJX3yBj40WKd3N9REnLFVrGKhCseNmJv3aw7as9tL18XqZpNRsk tJ6Ao0Qx4h1Aa0PJaCh2ltJBx3MxfTx0kwZCRo24RQKn37A/7TPCKstmK1eWxfh3pl/O czexEV6WRUcIOXrTzrb6V4KH3zI3RICsAVetBYVeCF5WwNFhMMTEAtlMBOGEAbhr/1PJ KA2uZAtVlL1NwFjLYt4fFk2ipMEkuKLZuZOdKZNyf8zZZ/2waTKQBEeIJc+blh93wCJS dDrpZDvcj1Vh9+XAPm2V43f3miwHSKixijo4OyLLFQ1VqBdmTnSi+w9hskT1cG8ivaUS vp1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700478681; x=1701083481; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6drtkgiEQeLI8ZZiBr8mtZ0Rl4GAMb/OR3BlfwpnCds=; b=qUQfBRrmKTqnfzv0pqCULNBUbDRqeYbbTiAffTU3rabGDHO1UTqBIHLN8xKFwAwLlU IPy0fh1/Fuz0o+K8Pjz4kiFMry8xQ3Zy7CAxJFSwSxuCO2NEYAxfyGOuLkMFbgNYkvmR viL9RSmQtHKNUAOTEtC+hJEz88aDrdSR8/18k716NRzNsXbXlWpo5SEqsHAKJHNxKzoh 7TUSlqfxwSc4/nEYNyeXWQ7F8Ve0lMlWGppGpM8jZdLp/GoWjFmCW7K6ujMJodd3azgc PHZ4R1M8Gl6hAzmO9cWb1pyVxaRcWgaTAoG9YlRhAYiytRVsr+4250WCVeOcwZ3n13od flIw== X-Gm-Message-State: AOJu0YyMtBnaZwJMB2IngoDmVS13Q/lsIwt5kaqFe0kYCdvoE5hEmPql 5y9MnstiCVxuWheXIcJyjrQ8LYY++9lhO9KtAhk= X-Received: by 2002:a05:6512:1255:b0:508:26c0:92d0 with SMTP id fb21-20020a056512125500b0050826c092d0mr5887528lfb.62.1700478681062; Mon, 20 Nov 2023 03:11:21 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id e29-20020adfa45d000000b0033169451a84sm10868947wra.29.2023.11.20.03.11.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:11:20 -0800 (PST) From: "plaisthos (Code Review)" X-Google-Original-From: "plaisthos (Code Review)" X-Gerrit-PatchSet: 1 Date: Mon, 20 Nov 2023 11:11:19 +0000 To: flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I7511bc43cd6a0bcb89476f27d5822ab4a78d0d21 X-Gerrit-Change-Number: 446 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 83fcdcee4454b7fc200f396d4572ff644953e103 References: Message-ID: <36a59041b20ad2903c425b5510e0e273bffe33c9-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.167.50 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.167.50 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1r52Bc-00Awqm-2v Subject: [Openvpn-devel] [M] Change in openvpn[master]: Remove dead list test code X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1783081186667691028?= X-GMAIL-MSGID: =?utf-8?q?1783081186667691028?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/446?usp=email to review the following change. Change subject: Remove dead list test code ...................................................................... Remove dead list test code Change-Id: I7511bc43cd6a0bcb89476f27d5822ab4a78d0d21 --- M src/openvpn/init.c M src/openvpn/list.c M src/openvpn/list.h 3 files changed, 0 insertions(+), 191 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/46/446/1 diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 8c707a4..5618c69 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -865,11 +865,6 @@ return false; #endif -#ifdef LIST_TEST - list_test(); - return false; -#endif - #ifdef IFCONFIG_POOL_TEST ifconfig_pool_test(0x0A010004, 0x0A0100FF); return false; diff --git a/src/openvpn/list.c b/src/openvpn/list.c index 480f39d..dc4b1df 100644 --- a/src/openvpn/list.c +++ b/src/openvpn/list.c @@ -326,185 +326,6 @@ } -#ifdef LIST_TEST - -/* - * Test the hash code by implementing a simple - * word frequency algorithm. - */ - -struct word -{ - const char *word; - int n; -}; - -static uint32_t -word_hash_function(const void *key, uint32_t iv) -{ - const char *str = (const char *) key; - const int len = strlen(str); - return hash_func((const uint8_t *)str, len, iv); -} - -static bool -word_compare_function(const void *key1, const void *key2) -{ - return strcmp((const char *)key1, (const char *)key2) == 0; -} - -static void -print_nhash(struct hash *hash) -{ - struct hash_iterator hi; - struct hash_element *he; - int count = 0; - - hash_iterator_init(hash, &hi, true); - - while ((he = hash_iterator_next(&hi))) - { - printf("%d ", (int) he->value); - ++count; - } - printf("\n"); - - hash_iterator_free(&hi); - ASSERT(count == hash_n_elements(hash)); -} - -static void -rmhash(struct hash *hash, const char *word) -{ - hash_remove(hash, word); -} - -void -list_test(void) -{ - openvpn_thread_init(); - - { - struct gc_arena gc = gc_new(); - struct hash *hash = hash_init(10000, get_random(), word_hash_function, word_compare_function); - struct hash *nhash = hash_init(256, get_random(), word_hash_function, word_compare_function); - - printf("hash_init n_buckets=%d mask=0x%08x\n", hash->n_buckets, hash->mask); - - /* parse words from stdin */ - while (true) - { - char buf[256]; - char wordbuf[256]; - int wbi; - int bi; - char c; - - if (!fgets(buf, sizeof(buf), stdin)) - { - break; - } - - bi = wbi = 0; - do - { - c = buf[bi++]; - if (isalnum(c) || c == '_') - { - ASSERT(wbi < (int) sizeof(wordbuf)); - wordbuf[wbi++] = c; - } - else - { - if (wbi) - { - struct word *w; - ASSERT(wbi < (int) sizeof(wordbuf)); - wordbuf[wbi++] = '\0'; - - /* word is parsed from stdin */ - - /* does it already exist in table? */ - w = (struct word *) hash_lookup(hash, wordbuf); - - if (w) - { - /* yes, increment count */ - ++w->n; - } - else - { - /* no, make a new object */ - ALLOC_OBJ_GC(w, struct word, &gc); - w->word = string_alloc(wordbuf, &gc); - w->n = 1; - ASSERT(hash_add(hash, w->word, w, false)); - ASSERT(hash_add(nhash, w->word, (void *) ((random() & 0x0F) + 1), false)); - } - } - wbi = 0; - } - } while (c); - } - -#if 1 - /* remove some words from the table */ - { - rmhash(hash, "true"); - rmhash(hash, "false"); - } -#endif - - /* output contents of hash table */ - { - int base; - int inc = 0; - int count = 0; - - for (base = 0; base < hash_n_buckets(hash); base += inc) - { - struct hash_iterator hi; - struct hash_element *he; - inc = (get_random() % 3) + 1; - hash_iterator_init_range(hash, &hi, true, base, base + inc); - - while ((he = hash_iterator_next(&hi))) - { - struct word *w = (struct word *) he->value; - printf("%6d '%s'\n", w->n, w->word); - ++count; - } - - hash_iterator_free(&hi); - } - ASSERT(count == hash_n_elements(hash)); - } - -#if 1 - /* test hash_remove_by_value function */ - { - int i; - for (i = 1; i <= 16; ++i) - { - printf("[%d] ***********************************\n", i); - print_nhash(nhash); - hash_remove_by_value(nhash, (void *) i, true); - } - printf("FINAL **************************\n"); - print_nhash(nhash); - } -#endif - - hash_free(hash); - hash_free(nhash); - gc_free(&gc); - } - - openvpn_thread_cleanup(); -} - -#endif /* ifdef LIST_TEST */ - /* * -------------------------------------------------------------------- * hash() -- hash a variable-length key into a 32-bit value diff --git a/src/openvpn/list.h b/src/openvpn/list.h index 94d14f2..18afc54 100644 --- a/src/openvpn/list.h +++ b/src/openvpn/list.h @@ -33,8 +33,6 @@ * client instances over various key spaces. */ -/* define this to enable special list test mode */ -/*#define LIST_TEST*/ #include "basic.h" #include "buffer.h" @@ -114,11 +112,6 @@ uint32_t hash_func(const uint8_t *k, uint32_t length, uint32_t initval); -#ifdef LIST_TEST -void list_test(void); - -#endif - static inline uint32_t hash_value(const struct hash *hash, const void *key) {