From 6a4a6d584bf7a57cbcccc46555a01b594ec73aa7 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 14 Mar 2022 18:44:07 +0100 Subject: [PATCH] essl: fix logical bug in argument check https://pvs-studio.com/en/blog/posts/cpp/0790/#IDBDD4F1FD2D Reported in https://github.com/espressif/esp-idf/issues/6440 --- components/esp_serial_slave_link/essl_sdio.c | 20 ++++++-------------- tools/ci/check_copyright_ignore.txt | 1 - 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/components/esp_serial_slave_link/essl_sdio.c b/components/esp_serial_slave_link/essl_sdio.c index 58b6e75a47..56ac197abd 100644 --- a/components/esp_serial_slave_link/essl_sdio.c +++ b/components/esp_serial_slave_link/essl_sdio.c @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "essl_sdio.h" #include "esp_log.h" @@ -206,7 +198,7 @@ esp_err_t essl_sdio_init(void *arg, uint32_t wait_ms) ESP_LOGD(TAG, "Function 0 BS: %04x", (int) bs_read); // Set block sizes for functions 1 to given value (default value = 512). - if (ctx->block_size > 0 || ctx->block_size <= 2048) { + if (ctx->block_size > 0 && ctx->block_size <= 2048) { bs = ctx->block_size; } else { bs = 512; diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 965ecac3df..9bd4b6a20a 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -672,7 +672,6 @@ components/esp_rom/test/test_miniz.c components/esp_rom/test/test_tjpgd.c components/esp_serial_slave_link/essl.c components/esp_serial_slave_link/essl_internal.h -components/esp_serial_slave_link/essl_sdio.c components/esp_serial_slave_link/include/esp_serial_slave_link/essl.h components/esp_serial_slave_link/include/esp_serial_slave_link/essl_sdio.h components/esp_serial_slave_link/include/esp_serial_slave_link/essl_spi.h