From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E086E45D54; Wed, 20 Nov 2024 17:50:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C893340285; Wed, 20 Nov 2024 17:50:50 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 0DE7E4021E for ; Wed, 20 Nov 2024 17:50:48 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-21278f3d547so6189185ad.1 for ; Wed, 20 Nov 2024 08:50:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1732121448; x=1732726248; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=f2dc6NwUfGK89wMmXOmtRgFunF71RFHPy8TPwbiNsY0=; b=LIATF6g8oNdZM+5Upqg5Tw8a6O/03u4zaf2W9+KstXQFh+CHGrowuLPSJrT6z0Y9GR Gu4f2jFjN4ijetIFlZ0c++hmt9D+3T+TFQ4xIx4uyaaMVdAuP6UZb64xo+9AEZRq7QI6 6h9hxa+UpnaW7cS0KQdYukHBaGWcDZpELYXj4fzGYXyMmtlb9GbmmiTLN71w0P9W6v9u q8PMRFbx4qx1c/8y9sr5oQzJrDfgGCPMnM5AmGLaXFE/jfIKceXYR9Yr2AwMSJgwDIKY qtFz2KD0tL6s14F+uP7K70h2E5vW9iiTKKmLF4MtcLPKzbENDqxwSxQ3wB8rtmOg6A4G wD2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732121448; x=1732726248; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f2dc6NwUfGK89wMmXOmtRgFunF71RFHPy8TPwbiNsY0=; b=QpaXYSdKBhS6b0rmt+4ltpjLC0xqy/gxXeVzcUaSeRNipmgNtZsKKz1e13oHDnrHXh VDLP5K6tDcNC+iVeP4qLhq9Sdpwy8HtvpSgZ+qo7l/CJ0I1/6n1U+o6P2R/eijUQayLv AeOFlkbzUB861xeX/lE0OXiO16B96AaIFHJHxnfg6Qc/J/whCQULfXxEr9qh5JLQaE+D XsdwCPmmlvbHwTEapLwscuerXvJ3qDERFCdq2M5Lf1Jl0QMKar+pDVRU7t4XihhRWke9 Ub+vFa2QNg1e+wsm3msC+80EevYm/YGP9mHboNgR0IVUNH3fV/igEoUE2Vaa20pyzGaJ 79Gg== X-Gm-Message-State: AOJu0Yz7HxViXTeM9WhcnkB4Rngs589QBssv+/XhA7HPT/yy4Z2HIGJV dFZ1Hdr71fWfuZL8yF89Sgq06UcofnwK8ApdopwLCVrO5XyrxGzXwajJl5x0pFWOI1yETxOkQK4 0 X-Google-Smtp-Source: AGHT+IFIuL1GGtekJWh67Pj9sm+WFE9SgxwQWt4D4FkMHwxWyg6kBaaE1nv+oy2rhlwCLtjrBBdkIQ== X-Received: by 2002:a17:902:d4ca:b0:212:4751:ad7e with SMTP id d9443c01a7336-2126a33ec85mr42633645ad.8.1732121448017; Wed, 20 Nov 2024 08:50:48 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211f6b25339sm75868005ad.240.2024.11.20.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2024 08:50:47 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH] test/cfgfile: add check for file removal Date: Wed, 20 Nov 2024 08:50:34 -0800 Message-ID: <20241120165034.69466-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The test makes temporary files for parsing and then cleans up. It was not checking the return value from the remove step which makes Coverity unhappy. Coverity ID: 451207 Coverity ID: 451209 Coverity ID: 451212 Coverity ID: 451213 Coverity ID: 451215 Coverity ID: 451217 Coverity ID: 451222 Coverity ID: 451225 Fixes: be22019a58c4 ("test: restore cfgfile tests") Signed-off-by: Stephen Hemminger --- app/test/test_cfgfile.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/app/test/test_cfgfile.c b/app/test/test_cfgfile.c index 8146435033..b189d9d7a5 100644 --- a/app/test/test_cfgfile.c +++ b/app/test/test_cfgfile.c @@ -108,7 +108,8 @@ test_cfgfile_sample1(void) ret = rte_cfgfile_close(cfgfile); TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); return 0; } @@ -137,7 +138,8 @@ test_cfgfile_sample2(void) ret = rte_cfgfile_close(cfgfile); TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); return 0; } @@ -173,7 +175,8 @@ test_cfgfile_realloc_sections(void) TEST_ASSERT(strcmp("value8_section9", value) == 0, "key unexpected value: %s", value); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); char tmp[PATH_MAX] = "/tmp/"; #ifdef RTE_EXEC_ENV_WINDOWS @@ -184,7 +187,9 @@ test_cfgfile_realloc_sections(void) ret = rte_cfgfile_save(cfgfile, filename); TEST_ASSERT_SUCCESS(ret, "Failed to save to %s", filename); - remove(filename); + + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); ret = rte_cfgfile_close(cfgfile); TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); @@ -205,7 +210,9 @@ test_cfgfile_invalid_section_header(void) cfgfile = rte_cfgfile_load(filename, 0); TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); + return 0; } @@ -227,7 +234,9 @@ test_cfgfile_invalid_comment(void) cfgfile = rte_cfgfile_load_with_params(filename, 0, ¶ms); TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); + return 0; } @@ -244,7 +253,9 @@ test_cfgfile_invalid_key_value_pair(void) cfgfile = rte_cfgfile_load(filename, 0); TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); + return 0; } @@ -277,7 +288,9 @@ test_cfgfile_empty_key_value_pair(void) ret = rte_cfgfile_close(cfgfile); TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); + return 0; } @@ -294,7 +307,9 @@ test_cfgfile_missing_section(void) cfgfile = rte_cfgfile_load(filename, 0); TEST_ASSERT_NULL(cfgfile, "Expected failure did not occur"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); + return 0; } @@ -328,7 +343,9 @@ test_cfgfile_global_properties(void) ret = rte_cfgfile_close(cfgfile); TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); + return 0; } @@ -351,7 +368,9 @@ test_cfgfile_empty_file(void) ret = rte_cfgfile_close(cfgfile); TEST_ASSERT_SUCCESS(ret, "Failed to close cfgfile"); - remove(filename); + ret = remove(filename); + TEST_ASSERT_SUCCESS(ret, "Failed to remove file"); + return 0; } -- 2.45.2