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: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-2.0 required=3.0 tests=AWL,BAYES_00,BODY_8BITS, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 342531F463 for ; Sat, 28 Dec 2019 20:43:46 +0000 (UTC) Received: from localhost ([::1]:46142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilIw4-0005Py-JV for normalperson@yhbt.net; Sat, 28 Dec 2019 15:43:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52806) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilIw0-0005Ps-Ot for bug-gnulib@gnu.org; Sat, 28 Dec 2019 15:43:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ilIvz-0007vV-Gu for bug-gnulib@gnu.org; Sat, 28 Dec 2019 15:43:40 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:44063) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ilIvz-0007pS-79 for bug-gnulib@gnu.org; Sat, 28 Dec 2019 15:43:39 -0500 Received: by mail-ed1-x530.google.com with SMTP id bx28so28583252edb.11 for ; Sat, 28 Dec 2019 12:43:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=yVh7DEF4f6L4260h7hljzL3a+Lfa/Dbrk2owHA+fXSk=; b=JikRXEyKiCYnIkcZiMGqw09FPEHnTMm4oKwWnPdUvdJaGz5rKuyKUMj17UY0LVTC+N BcqvRae22BPY33ZK/nosAVjzj/FNfLeXCsGt9zCl6pKV4CFaBXBfyqFIUAvDrFEn+NK0 ShaIUDUy0hCnlQdcQOvW+iTUUV50YZ1lxR1kBMfk08MsCFOAuSreTR9XVOXuOp5Lr8BK qBeXNbMtByKBDwda4IkdN8xYxXsOPL3hOl2rhvqhdBVozuYpUWBmjZMu7asA5SXxYIQ3 3fE6vrtGUIdHmpQhwno7rMCr5FmDcoirEHSouGnXrqihIZfuM059S1t9iAxS/NzM3sjb EHJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=yVh7DEF4f6L4260h7hljzL3a+Lfa/Dbrk2owHA+fXSk=; b=PNgJvNqorKqakv06833B1xtQUmM+EL4G4BOuzqllx+m+ea6pu/krH9u+D7SIZGSaC6 KNHkSxuvru96qSPQtEXG0frZBiPgQVbmrP+Ol0f8uOAyl3Cz1ABvYnPL8+7IcOf3aSvn Wbr6yQaUgc5w6fi9XOqYfx4qsyUdT9E7YgRBPS5fxm5k64/oRaxCRaWTyRYAKt1ytCiG YvBZwpNbozTU0zoPSU7lfL5o8OrPcIfoNmfM0CLzj3CualJosi+m5iPrikfuTAcxV35D jaeagb6ThnWI+ky/T6x+az/N0YISCu6dQwJD0u+fJHiQt9aB5U2P9cJxjAs6dp4BSzEP XyzA== X-Gm-Message-State: APjAAAU1wMXjxrM3NVsYsNxZq73LNFNVGug+2/VGrJJDkuC7tHzVNS8b 2H7yKBtZ7tamQOV8umdFF8A= X-Google-Smtp-Source: APXvYqw3JeSaiAcfP9y4TxbWQ3LvBYG9zfFTCFuZdzXXYkpH8BWSdm1DbAEPAKep9KbOCBNJm8jiRw== X-Received: by 2002:a17:906:7f02:: with SMTP id d2mr61978328ejr.261.1577565817806; Sat, 28 Dec 2019 12:43:37 -0800 (PST) Received: from localhost (ppp046176149051.access.hol.gr. [46.176.149.51]) by smtp.googlemail.com with ESMTPSA id t1sm4751662ejg.32.2019.12.28.12.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2019 12:43:36 -0800 (PST) Date: Sat, 28 Dec 2019 22:44:00 +0200 From: ag To: Paul Eggert Subject: Re: string types Message-ID: <20191228204400.GA789@HATZ> References: <175192568.e2XXTFFdkW@omega> <20191226221225.GA800@HATZ> <2179574.G9OhZXe8sF@omega> <20191228131438.GA797@HATZ> <1c20e1d7-33fa-292a-731f-d2e5b56acb6d@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1c20e1d7-33fa-292a-731f-d2e5b56acb6d@cs.ucla.edu> User-Agent: Mutt/1.12.1 (2019-06-15) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::530 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bruno Haible , Tim =?utf-8?Q?R=C3=BChsen?= , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Paul, On Sat, Dec 28, at 10:28 Paul Eggert wrote: > > Based on the above assumptions this can be extended. First instead of size_t to > > return ssize_t, so functions can return -1 and set errno accordingly. > > It's better to use ptrdiff_t for this sort of thing, since it's hardwired into > the C language (you can't do any better than ptrdiff_t anyway, if you use > pointer subtraction), whereas ssize_t is merely in POSIX and is narrower than > ptrdiff_t on some (obsolete?) platforms. So, let's say we designed this thing without obligating to the past and thinking for the next hundred years (of course with the current knowledge and to lessons from the past), and wanted to make it work with malloc and string type functions, as best it can be done and without worries for overflows and unsigned divisions and all this kind of confusing things that hunts us altogether after so many years that things should have been settled by now... is your opininion that this is adequate? typedef ptrdiff_t msize_t (m for memory here) > > #define MUL_NO_OVERFLOW ((size_t) 1 << (sizeof (size_t) * 4)) > > #define MEM_IS_INT_OVERFLOW(nmemb, ssize) \ > > (((nmemb) >= MUL_NO_OVERFLOW || (ssize) >= MUL_NO_OVERFLOW) && \ > > (nmemb) > 0 && SIZE_MAX / (nmemb) < (ssize)) > > Ouch. That code is not good. An unsigned division at runtime to do memory > allocation? Gnulib does better than that already. Also, Glibc has some code in > this area that we could migrate into Gnulib, that could be better yet. Sorry, i don't have time to do it right now - as i just escaped from a snow-storm - but i will check this for atleast not to spread misleading information (is quite possible my fault here), so thanks for your comment. By the way Paul and since i'm self taught by practical experience kind of human being and joking with zoi here said that at least my teacher is a hall of famer in the computing history. Isn't this life great! So true this is also a school for free afterall. My Honor, Αγαθοκλής