From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by sourceware.org (Postfix) with ESMTPS id 65D663858D39 for ; Mon, 24 Jan 2022 12:53:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 65D663858D39 Received: by mail-oi1-x235.google.com with SMTP id x193so25404495oix.0 for ; Mon, 24 Jan 2022 04:53:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=o8qvhSTpEl9pFjuzmEbK34SwtY9E5yfv5FOZkxdCkD8=; b=rrrzmAt3U0/9scvmL+IzIT7GL+BsPezUVBCbZIzMIQMGVmy2tRH9Ra2UMcMTO+Kh9R IChQPa5p0fwQ83JQG8mZUadMl9EQpyTFPjoIoaOx90YxZrr3dhsVZfSMvR0i0ueM2ttT ic08WzFvHWVYsDk0n/4fsGJUe6OxwOESawEFIvsu9NBnghH3rXk/m2LOqojkH3JjnQtA Npp47s5gGWI25TsGS9FUXPTuVFa9bqHqu3T8IffBTvuUZDzMS6NTIKLT0ZVa2vrC09ZY G+SfDDTC7shCPX+gX676eeNaXdZxHpIMpHKu3w95/oOQzIFmSFIjhdCPKtLQT1q5N0xJ Jqng== X-Gm-Message-State: AOAM530PiayXDgmeQmjfSQJBpiOjPmcCb0k3DejuRtkU0VH1A8lz66Bl 3W2yhmA5CEDjKjGTkOFSKelfGg== X-Google-Smtp-Source: ABdhPJxXdemZRHScKlkr+k3D9RLlU89aIQSl4QbiNSsd0mgrCiU1/6BJcFCfRO2Ge2hwNlSmVfKe1w== X-Received: by 2002:aca:5b03:: with SMTP id p3mr1185624oib.15.1643028790739; Mon, 24 Jan 2022 04:53:10 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:27f8:c505:63c0:de61:b716? ([2804:431:c7cb:27f8:c505:63c0:de61:b716]) by smtp.gmail.com with ESMTPSA id q23sm1407128ota.38.2022.01.24.04.53.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jan 2022 04:53:10 -0800 (PST) Message-ID: Date: Mon, 24 Jan 2022 09:53:07 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v10 1/4] elf: Add la_activity during application exit Content-Language: en-US To: Florian Weimer , Adhemerval Zanella via Libc-alpha Cc: jma14 , Carlos O'Donell , John Mellor-Crummey References: <20220117213136.1327053-1-adhemerval.zanella@linaro.org> <20220117213136.1327053-2-adhemerval.zanella@linaro.org> <874k5x8irn.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella In-Reply-To: <874k5x8irn.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 24 Jan 2022 12:53:13 -0000 On 21/01/2022 07:50, Florian Weimer wrote: > * Adhemerval Zanella via Libc-alpha: > >> +static int >> +do_test (int argc, char *argv[]) >> +{ >> + /* We must have either: >> + - One our fource parameters left if called initially: >> + + path to ld.so optional >> + + "--library-path" optional >> + + the library path optional >> + + the application name */ >> + if (restart) >> + return handle_restart (); >> + >> + char *spargv[9]; >> + int i = 0; >> + for (; i < argc - 1; i++) >> + spargv[i] = argv[i + 1]; >> + spargv[i++] = (char *) "--direct"; >> + spargv[i++] = (char *) "--restart"; >> + spargv[i] = NULL; > > Please add a check for an out-of-range argc value, or allocate the array > on the heap. Ack. > >> + while (xgetline (&buffer, &buffer_length, out)) >> + { >> + if (startswith (buffer, "la_activity: ")) >> + { >> + uintptr_t cookie; >> + int this_act; >> + int r = sscanf (buffer + strlen ("la_activity: "), >> + "%d %"SCNxPTR"", &this_act, &cookie); >> + TEST_COMPARE (r, 2); > > I wonder if you can fold the startswith check into the sscanf. At least > you could put "la_activity: " into the format string. Ack, I have changed to la_objopen and la_objclose as well.