From owner-svn-src-head@freebsd.org Tue Sep 17 23:18:23 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E81DCEA08B; Tue, 17 Sep 2019 23:18:23 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46XzYq5rLlz4pB9; Tue, 17 Sep 2019 23:18:23 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io1-f41.google.com with SMTP id q10so11798777iop.2; Tue, 17 Sep 2019 16:18:23 -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:reply-to :from:date:message-id:subject:to:cc; bh=510hRvj20U2t/iOIkqm++Rn80Ilexx8vJrOB+SdJdCs=; b=De/7+lQAgeTD0ynkebGaN4L3mU1wKna+p7UKwlJqycybxIRDK99S6v8vY7YHm+fkpN XUj0wQ799SnRpG7iPGOvMJ6NhSCNJfBVpCeF3+zcOmrUbC6ZWysKR4+Kqdik/uE9PXR5 Lr6B0fWTP/BxkvOfDy0PLFWMgF41kkbgYjO/QUdOfAeUM9psH3PHcONXMIkIj7wsWCsq nKraPFGSN3yoNHP6TvdkYjDHAViDuZEY3AFCAtkUSpbotgyFruCznvZziH4YjEQcNVms VgVXrrHang6mZI/evlm0j4rD6X5S+PpAkf08lpwOGhoDTOdTG/5hHtwmEtqdrDWn/nh3 AvTQ== X-Gm-Message-State: APjAAAXJiRH/THqStrVvOjJj8K3omMl47u3P0TpdRCVZGSU48483S/vh 8QO95gwbRFy31CG5MY6hdU3wnXfD X-Google-Smtp-Source: APXvYqwZF7VI2ncr0Cl4BzYd2bj/9rh+C007Nsj+MNp5dQE/Pu67aXqPlBt+8nI6kP2Ug6JM5XFHDQ== X-Received: by 2002:a5d:964f:: with SMTP id d15mr1743204ios.230.1568762302394; Tue, 17 Sep 2019 16:18:22 -0700 (PDT) Received: from mail-io1-f48.google.com (mail-io1-f48.google.com. [209.85.166.48]) by smtp.gmail.com with ESMTPSA id w22sm3563475ior.79.2019.09.17.16.18.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Sep 2019 16:18:21 -0700 (PDT) Received: by mail-io1-f48.google.com with SMTP id j4so11629024iog.11; Tue, 17 Sep 2019 16:18:21 -0700 (PDT) X-Received: by 2002:a6b:5b0a:: with SMTP id v10mr1789018ioh.80.1568762301761; Tue, 17 Sep 2019 16:18:21 -0700 (PDT) MIME-Version: 1.0 References: <201909171616.x8HGGlkb066218@repo.freebsd.org> In-Reply-To: <201909171616.x8HGGlkb066218@repo.freebsd.org> Reply-To: cem@freebsd.org From: Conrad Meyer Date: Tue, 17 Sep 2019 16:18:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r352451 - head/stand/libsa To: Toomas Soome Cc: src-committers , svn-src-all , svn-src-head Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46XzYq5rLlz4pB9 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Sep 2019 23:18:24 -0000 Well, hang on; it's also perfectly legal for a malloc implementation to return NULL for requests of zero bytes. You can access exactly the number of bytes requested in the allocation; and free(NULL) works as expected. NULL (0) is also aligned to any size you could want. Best, Conrad On Tue, Sep 17, 2019 at 9:16 AM Toomas Soome wrote: > > Author: tsoome > Date: Tue Sep 17 16:16:46 2019 > New Revision: 352451 > URL: https://svnweb.freebsd.org/changeset/base/352451 > > Log: > loader: revert r352421 > > As insisted by kib, malloc(0) is quite legal. > > Modified: > head/stand/libsa/zalloc_malloc.c > > Modified: head/stand/libsa/zalloc_malloc.c > ============================================================================== > --- head/stand/libsa/zalloc_malloc.c Tue Sep 17 15:53:40 2019 (r352450) > +++ head/stand/libsa/zalloc_malloc.c Tue Sep 17 16:16:46 2019 (r352451) > @@ -73,9 +73,6 @@ Malloc_align(size_t bytes, size_t alignment) > { > Guard *res; > > - if (bytes == 0) > - return (NULL); > - > #ifdef USEENDGUARD > bytes += MALLOCALIGN + 1; > #else