From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by sourceware.org (Postfix) with ESMTPS id D0AFB3890410 for ; Fri, 18 Jun 2021 20:07:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D0AFB3890410 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rtems.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f179.google.com with SMTP id d13so15521472ljg.12 for ; Fri, 18 Jun 2021 13:07:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:from:date:message-id :subject:to; bh=rjBzAegJb3e+YJPTALGV5e0JBHnkFos/gGzcUuh6BpM=; b=nIMfBhcXRhbDqVjpYkBfcBmaCTTqwLNve+HpcaEbGsHHF471s9SoYXWrvt0N2wBW5v 5xtem0FZ0zT6JYfFFM/3UVQU8FmmmgrC3ufglr3AWfJ7It4UQAZGAUbrgrbkzIq8P+lW U7bgLQ05Xo2F/M53UTu5C2KsUJg/XooOGQ4t3x4ZJN9XQTjCVREPZHebejVxFtOfDA48 tejDjV6OaoTVoudgAQY7PopTnKO1y3KgoemVkoWoPbWfZ8DL3/brFHWs/I5tQczsDll0 Kb4KQbNbeMZuQlG6gTjMKxE3SX4+xTpEVYZx5e8HkwFQAd1nifxs2XiCuLFUM09t3Atk +JpQ== X-Gm-Message-State: AOAM532iJC0QzLqPDaVVuxOv9/RJ32yUkY2SyPmD3E+DuW5xUOx0XpoY MWtL3lpJ8d9/InRJ+uhVWpXhV5A4fOmhug== X-Google-Smtp-Source: ABdhPJyeGT9tGhLYZLLTiZh54gbCIioNaacuKTOtN0zY4owjtvMLHzsQX4ezFqQ4ecAaodWSdj72ig== X-Received: by 2002:a2e:581e:: with SMTP id m30mr11141238ljb.170.1624046851837; Fri, 18 Jun 2021 13:07:31 -0700 (PDT) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id i30sm996510lfv.298.2021.06.18.13.07.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Jun 2021 13:07:31 -0700 (PDT) Received: by mail-lf1-f42.google.com with SMTP id x24so18498927lfr.10 for ; Fri, 18 Jun 2021 13:07:31 -0700 (PDT) X-Received: by 2002:a05:6512:38c1:: with SMTP id p1mr4670659lft.50.1624046851516; Fri, 18 Jun 2021 13:07:31 -0700 (PDT) MIME-Version: 1.0 Reply-To: joel@rtems.org From: Joel Sherrill Date: Fri, 18 Jun 2021 15:07:20 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Unchecked Return Value in stdio.c To: Newlib Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3031.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jun 2021 20:07:35 -0000 Hi I hope this email's formatting isn't an issue. I converted the Scan output to plain text. Looking through Coverity Scan's report, I see this: 85 if (fp->_flags & __SAPP) CID 175328 (#1 of 1): Unchecked return value (CHECKED_RETURN)2. check_return: Calling _lseek_r without checking return value (as is done elsewhere 7 out of 8 times). 86 _lseek_r (ptr, fp->_file, (_off_t) 0, SEEK_END); 87 fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */ If the _lseek_r() fails, shouldn't this return an error? Looking at where it appears to get called indirectly, it looks like it is acceptable for this return -1. If this can't fail or it isn't an issue if it fails, then this should have (void) added along with a comment. Looking at the POSIX standard, the lseek() should fail if the fildes argument is associated with a pipe, FIFO, or socket. It may mean an errno of ESPIPE is acceptable and the method should continue. https://pubs.opengroup.org/onlinepubs/009696699/functions/lseek.html Suggestions on how to resolve this appreciated. Thanks. --joel