From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_REPLYTO_END_DIGIT, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 11BFA1F49B for ; Wed, 25 Mar 2020 17:59:31 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1C842382EAC2; Wed, 25 Mar 2020 17:59:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C842382EAC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1585159170; bh=iUnak6lkUeaXkGWp5Ngbqr4/XqOXzMUGeB56eNKPDn4=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=oDG/KnqTC1+fchM2rJebwY5UwBImiOe/8WVyhryQCP/H2WwlsoN08lRjpE/E2ZZgy guz6r1WtKBfGBmlSQ5wdPYjj6DY288/3izptrvmiSxnN7WMnmJHY6OHq5si0cM+bQC dj4r8XtTgGBVM8/ccFEHZyrMRSihXLH7FMjr0/us= Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by sourceware.org (Postfix) with ESMTPS id B6A42385E00D for ; Wed, 25 Mar 2020 17:59:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B6A42385E00D Received: by mail-wr1-x442.google.com with SMTP id s1so4352796wrv.5 for ; Wed, 25 Mar 2020 10:59:26 -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; bh=iUnak6lkUeaXkGWp5Ngbqr4/XqOXzMUGeB56eNKPDn4=; b=bxFiR+5fNrdzdvQabg8FTB6D2NYupe019btb2IrwZMHF8md8YemlDE161q23lA7O+V O5WFwIUG2WpHBOqFvRoRwTNGrqXXCz67lESV7yQRJie+IiQWYqTfSm7iRAlubrhDfYuT lWYGZNFiEop07aYN5iFTybq/itoR1wdnQ7FrJ/CRaHEYZwABKJPVBUC2cmEJuCHY6WTH LGTddYkOviUjbJfvoKbt0GKfsGGlUQ7wHfcZ9sAgrH4/rSOPTp+ZI8cGULYVGa0U6sZY 9o93ksAQc31Ep7ifUEIo+h7nV/s/KLwvUtL3o2BbkQlfW6By5iQbMU+9GuVRIgdvVZv4 Y3Fw== X-Gm-Message-State: ANhLgQ36IlNiQMvWuEx5JhO5CNKChLY+lbZpHX/AnpSj9lcCDexELFCm vm6HvVZvriDal78YUFjdia4CBkUQlfdymo/sqRhnPg== X-Google-Smtp-Source: ADFU+vsrVoba99BF8FfB+HIYWV9H4KasVYapzkFub7A6rKQ29RDbV9cMV0jJVHDnwp8+r1D4B8ZkavloBjb1TPH67sQ= X-Received: by 2002:a05:6000:108c:: with SMTP id y12mr4621313wrw.211.1585159165428; Wed, 25 Mar 2020 10:59:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 25 Mar 2020 23:29:14 +0530 Message-ID: Subject: Re: [PATCH] manual: Fix backtraces code example [BZ #10441] To: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Girish Joshi via Libc-alpha Reply-To: Girish Joshi Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Ping. Girish Joshi On Tue, Mar 10, 2020 at 9:40 PM Girish Joshi wrote: > > From bd99113d312012bde774a66c36b4894355175661 Mon Sep 17 00:00:00 2001 > From: Girish Joshi > Date: Tue, 10 Mar 2020 17:15:08 +0530 > Subject: [PATCH] manual: Fix backtraces code example [BZ #10441] > > Validation for pointer returned by backtrace_symbols () added. > Type of variables size and i is changed from size_t to int. > > Variable size is used to collect the result from backtrace () > that is an int. i is the loop counter variable so it can be an int. > > Since, size_t size is changed to int size, in printf %zd is changed to %d. > --- > manual/examples/execinfo.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/manual/examples/execinfo.c b/manual/examples/execinfo.c > index a789b6b5a7..01fd2d2dc2 100644 > --- a/manual/examples/execinfo.c > +++ b/manual/examples/execinfo.c > @@ -24,17 +24,18 @@ void > print_trace (void) > { > void *array[10]; > - size_t size; > char **strings; > - size_t i; > + int size, i; > > size = backtrace (array, 10); > strings = backtrace_symbols (array, size); > + if (strings) > + { > > - printf ("Obtained %zd stack frames.\n", size); > - > - for (i = 0; i < size; i++) > - printf ("%s\n", strings[i]); > + printf ("Obtained %d stack frames.\n", size); > + for (i = 0; i < size; i++) > + printf ("%s\n", strings[i]); > + } > > free (strings); > } > -- > 2.21.1 > > > Girish Joshi