From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by sourceware.org (Postfix) with ESMTPS id 179843972474 for ; Tue, 23 Jun 2020 18:18:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 179843972474 Received: by mail-qt1-x843.google.com with SMTP id d27so16150153qtg.4 for ; Tue, 23 Jun 2020 11:18:52 -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:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dEoyi3HwyK4KHwta8Xmql8L2q7pDctYDtm76zz57Sj0=; b=CoftWaYxlGA9m0gCnz4yl2cKQLPNcCwulM4S1NC9k76rMdvud5G1I+jGJPT1KVZ0BJ nP1RDJj2DFFAkl8NSvfAqtAvp/LdZcv9+58KztVJiOFMkLjjhlAstOmy8tYD3Cdw59qm Mqeo0Xrsd/Z1V5ara11JsARVlPfvym1l8tlYwKadBFsEU9A9lUovq1QhTPxEpCn/O5ub C3465ByW5+x+9AO4rGLiCDRWZeWbcuuuFNto+HryGRsIHA8uKmbf455uis1f4o3I8cMx /LILzrPv8651sWSWM6eBSYnX+hvSvGicps7RqGA2FHQ0fS4sdyDwWsZrfbWU9y1XH86E kyRg== X-Gm-Message-State: AOAM5313o8kywHG+gzKLPs2hF8ky/IBEn/euw0ximRnU/U6ByHU22RZh x4j8Goi+ioYk4dcQEILeWE/jr00Uqclxx72QIseOoekw X-Google-Smtp-Source: ABdhPJy6z0c7gEDdXtbfSgSs4k6B02fKixkgnFmN43yU5tjxMav7YDj4tVpnTEDLF5u0jsvCO0ie+Jm9z8lkKzwzPdA= X-Received: by 2002:ac8:5484:: with SMTP id h4mr19436963qtq.322.1592936331429; Tue, 23 Jun 2020 11:18:51 -0700 (PDT) MIME-Version: 1.0 References: <20200623132006.15863-1-tom@tromey.com> <20200623132006.15863-3-tom@tromey.com> In-Reply-To: <20200623132006.15863-3-tom@tromey.com> From: Christian Biesinger Date: Tue, 23 Jun 2020 13:18:14 -0500 Message-ID: Subject: Re: [PATCH v2 2/7] Add "help news" To: Tom Tromey Cc: gdb-patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.5 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jun 2020 18:18:53 -0000 On Tue, Jun 23, 2020 at 8:20 AM Tom Tromey wrote: > +static void > +help_news (struct ui_file *stream) > +{ > + std::string news_name = std::string (gdb_datadir) + SLASH_STRING + "NEWS"; > + gdb_file_up news_file = gdb_fopen_cloexec (news_name.c_str (), "r"); > + if (news_file == nullptr) > + perror_with_name (_("could not open the NEWS file")); > + > + char buffer[1024]; > + size_t offset = 0; > + while (true) > + { > + size_t nbytes = fread (&buffer[offset], 1, sizeof (buffer) - offset, > + news_file.get ()); Why not use read_entire_file from your other patch? Christian