From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 10615 invoked from network); 26 Jun 2020 06:27:25 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 26 Jun 2020 06:27:25 -0000 Received: (qmail 24480 invoked by uid 550); 26 Jun 2020 06:27:22 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 24461 invoked from network); 26 Jun 2020 06:27:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=37uqPI5yN0WWwr5c85B8VwoAJah/ypcRQxPmMbubvlo=; b=Z+KI9Eji6oI5gJEGPvIjsvbbsl7TVf8+31e6woI/gO7g89G+w/LS04L1hoKhRPP6qB dYf3h1WN16X07NBkXWTQULmJweIcMM2Wz51WbZGdJoumuBcgA5j+gpdbpc6O58lKN1YF qJySwi2mG7AvmkouF7PuU+FMqm8KTny1OoH353R/zh/p4p1donXatcwPHCNEJmQ/SCYT tiHnnNGhC8wj2d2nUYJ5eMuM1RjrP+Qy2WG8JaLpo39rQV8pZjy4fDcBj69RqCrnN9lC DtdkNk5+rIOlGzOncnuwnMH4SZmj53a7j1FACeJPYVISLs2qa1m7IcuViatLutJauqj6 vtvA== 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=37uqPI5yN0WWwr5c85B8VwoAJah/ypcRQxPmMbubvlo=; b=WsACJsVJR1MyApC0HF/tr6GXa6h5jxV0q5XPSIz5QAYqp3xtp67zK/hwEwwy3MGi80 MITR+Bo825ibMAq4GLjIQbQuR9p13zJpgiLeA3djWzGKoAMzRCnp+ViDr5wda4py9SUt z8+rXqY115ylm1HJtLqH3kDXQP3/FmhxtR9vcdQAcyQ9DDUMkkqsNMXF4REyax/Pn1Dv J8YlrDO38wBicIcnrqYHu67W/azQ6xxsdMTxWxNGFRPldEhW1ODQfVtDYRfVXR6KR1xt ZdV5qzScEKfpLhTORE6yU+PaPISnbfRWlTwFQocVFcXeRnzWvrwqeTqdZdSKkUd45T7j qi2A== X-Gm-Message-State: AOAM530PwqeENvEh32yFPXpl50Fn3AEe7Mjc6MCb9uFBSXn8taW6gFD4 cKveAwRt3vpbE0vTRR0yXdWchp/9S+opqW4VIyZRTS2A X-Google-Smtp-Source: ABdhPJyEQpEmkx+YrJiW4kntp0QjwenXRraoEM4xId9rNTjsugfTxTPgN3ftAIuzRGeqkVB7H5lgk/NcgWQbA2/Udrw= X-Received: by 2002:a5d:8417:: with SMTP id i23mr1052993ion.132.1593152830446; Thu, 25 Jun 2020 23:27:10 -0700 (PDT) MIME-Version: 1.0 References: <20200624232008.4093-1-daniel.santos@pobox.com> <39be4d66-963c-4e06-e685-37a8396d10c3@gmail.com> In-Reply-To: From: Jeffrey Walton Date: Fri, 26 Jun 2020 02:26:59 -0400 Message-ID: To: musl@lists.openwall.com Cc: Khem Raj , Daniel Santos Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] [PATCH] Fix signed compare warning On Fri, Jun 26, 2020 at 2:20 AM Daniel Santos wrote: > > ... > >> if (at) { > >> - if (at->tv_nsec >= 1000000000UL) return EINVAL; > >> + if ((unsigned long)at->tv_nsec >= 1000000000UL) return EINVAL; > >> if (__clock_gettime(clk, &to)) return EINVAL; > >> to.tv_sec = at->tv_sec - to.tv_sec; > >> if ((to.tv_nsec = at->tv_nsec - to.tv_nsec) < 0) { > >> > > may be use < 0 || >= 1000000000L and avoid the cast. > > there is a similar issue in src/thread/pthread_cond_timedwait.c as well > Thank you for that. I'll resubmit changing both instances. > > In this case, the POSIX spec requires nt_nsec to be a long ( > https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html > ). Either way, a good optimizer should convert this into an unsigned I believe the C language says the signed value gets promoted to an unsigned value. I don't believe the optimizer has anything to do with it. That's why -1 is greater than 1 in C: int x = -1; unsigned int y = 1; if (x > y) printf("WTF???\n"); Jeff