From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 574683857C5F for ; Wed, 24 Mar 2021 16:39:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 574683857C5F Received: by mail-wr1-x432.google.com with SMTP id x7so2649583wrw.10 for ; Wed, 24 Mar 2021 09:39:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=z18aQKZ4UJsEjR4ExmGRpL4YGeU6FtSzq0Lm01VEgUw=; b=CttuFXun1qrgImW3h0hS6PlxMVfwAofskqgD9B80ALu9KN158PNXTB8JkN0joHLnik bgB9uAj5DO2Skgpn6FTVO5ayMUmTRn5Qw78faFP60MPsI+KxExR5GGZjMNrFYZKRdf88 yRQm7JjbNebik+Y2blTLY3fjNmFniU+cB2X18lidhT4OmW8WdWVR1KSKWlgDS4tGqgts 9IGugDkKBoGU0Gm4hGHrMzhNB8oFncIsmnQ+Nh/nQr5lvdbxwAqXWPYyVgDa102pkqpP qOhW0j7kNOf9atOPCL0prqN+VneMLfOpKpptDdvK7v0B6uRtnJn593IHhSrBRpVcMXdo zPLA== X-Gm-Message-State: AOAM530ur/2m0pxH7YGQ26SeKlrpjm/0bNf4lYcLFcPKXOZDUlMU8a1G sjxfGVAh/tGH+9vSHOQZdLo8NmWz6us= X-Google-Smtp-Source: ABdhPJwacxxOHCl4LaXAVQZoL+I109G+U3k1tg6Ft+acCeLbKTuJ5qj3z5WhyE9V0+loACtl5iUjOA== X-Received: by 2002:adf:a1d8:: with SMTP id v24mr4323149wrv.378.1616603947377; Wed, 24 Mar 2021 09:39:07 -0700 (PDT) Received: from [192.168.0.160] ([170.253.36.171]) by smtp.gmail.com with ESMTPSA id q207sm2953525wme.36.2021.03.24.09.39.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Mar 2021 09:39:06 -0700 (PDT) To: GNU C Library From: "Alejandro Colomar (man-pages)" Subject: printf_arginfo_size_function error handling Message-ID: Date: Wed, 24 Mar 2021 17:39:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: 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: Wed, 24 Mar 2021 16:39:10 -0000 Hi, I've been re-reading the docs for printf_register_specifier(), and there's something in an example code that doesn't make much sense: [[ int print_widget_arginfo (const struct printf_info *info, size_t n, int *argtypes) { /* We always take exactly one argument and this is a pointer to the structure.. */ if (n > 0) argtypes[0] = PA_POINTER; return 1; } ]] In the code above there is a check that n>0, but: What can a user do if n<=0 ? There's no error reporting method, is there? And, is it possible for such a case to happen? What to do there? I think either using an assert() or not checking at all might make more sense (depending on how possible is n<=0 to happen). The current check continues as if everything was fine, just without setting argtypes[0], so if there's an error, it will be carried to some future stage, where nasal daemons might unexpectedly happen. Thanks, Alex -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/