From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 826FDC64E8A for ; Thu, 3 Dec 2020 01:34:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19E0920C56 for ; Thu, 3 Dec 2020 01:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbgLCBdp (ORCPT ); Wed, 2 Dec 2020 20:33:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45469 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgLCBdp (ORCPT ); Wed, 2 Dec 2020 20:33:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606959138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=T+i4hgnbURlmHWFQ6sHh3xD+xz+pB56D5OvWJIuIZUg=; b=UBIH/+ZuQ4dzQeZ9WD7xzGVMi5EQrgaHZdfkrn/c8ub5ATVLj7vaIgNPiYZYI9Xwq/x8ue TaPVIXIgUtjrYjqAGeM1fpbTQY83U6nkb/b90ksZ/Eby/DnVeSdoJNUXHT2sAvD8YsmFbo q4hMT5QC2TmoTmb9SGEhycNJVcRy8NE= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-6kznJKuEP_aBzFq0TfFskQ-1; Wed, 02 Dec 2020 20:32:16 -0500 X-MC-Unique: 6kznJKuEP_aBzFq0TfFskQ-1 Received: by mail-qk1-f197.google.com with SMTP id s128so662100qke.0 for ; Wed, 02 Dec 2020 17:32:16 -0800 (PST) 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:in-reply-to; bh=T+i4hgnbURlmHWFQ6sHh3xD+xz+pB56D5OvWJIuIZUg=; b=dzXDMVxY7NDwmUh4S99rGD3y8VoM4VNr/226ANXtaQECmZAFLguHo63k+Bcw4qzfaV bkeX4MqdRbHQArKxBHqjI+OAnQGmw6wNaPds+/Vg8mibEuPNFK3mWu+NinB50+5HVcsg TLwRJJBTTDOulGDBCR7KvVRPsbC7NfXjegoZgrB8b6C6hb/ezqLl/kIUazpsF+PVD/Up jM2NgRe50OU24lhEe2+Cg9xSRNi3bnLRlQoHT67/RwMI4GczPadvKx9rQJLpXV+bhCj2 jHz7n+yvAuL0vtrwmVeOngAjpE6eTZ44hCBdf7p/zfvVV7DYzYXtrlJLf8Fsio1QKNWy vtbw== X-Gm-Message-State: AOAM531/rahVyhExSFExqX8ohL1q6/Hd0zn//SBVqVgJyQ3MHrkwnOSM MOhUnFh82R4ysIxnc2QnpwVafJrOz4EUecd3xYg9yis52enfDd9Hqvy2z2oVajTxD5to99G61gG ASMcxJZMmk48l/zEXOfnpHj/1 X-Received: by 2002:a0c:e583:: with SMTP id t3mr1117784qvm.42.1606959136166; Wed, 02 Dec 2020 17:32:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTRKK1oR4TGx3jghmRwEPH0SBs2kLQ15yxtOulZgmC1hCRslHbj2urqxef0p2YRznc+YWv2w== X-Received: by 2002:a0c:e583:: with SMTP id t3mr1117759qvm.42.1606959135831; Wed, 02 Dec 2020 17:32:15 -0800 (PST) Received: from xz-x1 ([142.126.94.187]) by smtp.gmail.com with ESMTPSA id m8sm547711qkn.41.2020.12.02.17.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 17:32:15 -0800 (PST) Date: Wed, 2 Dec 2020 20:32:13 -0500 From: Peter Xu To: Axel Rasmussen Cc: Shuah Khan , Andrew Morton , Joe Perches , Mike Rapoport , Andrea Arcangeli , David Alan Gilbert , Greg Thelen , linux-kselftest@vger.kernel.org, LKML Subject: Re: [PATCH] userfaultfd: selftests: make __{s,u}64 format specifiers portable Message-ID: <20201203013213.GE108496@xz-x1> References: <20201202211542.1121189-1-axelrasmussen@google.com> <20201202230954.GB108496@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 02, 2020 at 03:52:56PM -0800, Axel Rasmussen wrote: > On Wed, Dec 2, 2020 at 3:10 PM Peter Xu wrote: > > > > Hi, Axel, > > > > Looks mostly good to me, but a few nitpickings below. > > > > On Wed, Dec 02, 2020 at 01:15:42PM -0800, Axel Rasmussen wrote: > > > > [...] > > > > > +static void uffd_error(const char *message, __s64 code) > > > +{ > > > + fprintf(stderr, "%s: %" PRId64 "\n", message, (int64_t)code); > > > + exit(1); > > > +} > > > > IMHO a macro that can take arbitrary parameters would be nicer, but if it > > satisfy our need, definitely ok too. > > > > [...] > > > > > @@ -340,7 +348,8 @@ static void wp_range(int ufd, __u64 start, __u64 len, bool wp) > > > prms.mode = wp ? UFFDIO_WRITEPROTECT_MODE_WP : 0; > > > > > > if (ioctl(ufd, UFFDIO_WRITEPROTECT, &prms)) { > > > - fprintf(stderr, "clear WP failed for address 0x%Lx\n", start); > > > + fprintf(stderr, "clear WP failed for address 0x%" PRIx64 "\n", > > > + (uint64_t)start); > > > exit(1); > > > > Is it intended to not use uffd_error() here? > > Yes, this is intentional. This particular case prints the value in > hexadecimal, rather than decimal. > > (Agree that uffd_error() could be made more general to cover cases > like this. I opted for the simplest thing which covers all but two > cases - this one, and one where we "return 1;" instead of "exit(1);" - > but I don't feel strongly.) Actually it's as simple as: #define uffd_error(...) do { \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, "\n"); \ exit(1); \ } while (0) But it's okay, I think. > > > > > > } > > > } > > > > [...] > > > > > @@ -979,26 +981,20 @@ static int __uffdio_zeropage(int ufd, unsigned long offset, bool retry) > > > if (ret) { > > > /* real retval in ufdio_zeropage.zeropage */ > > > if (has_zeropage) { > > > - if (uffdio_zeropage.zeropage == -EEXIST) { > > > - fprintf(stderr, "UFFDIO_ZEROPAGE -EEXIST\n"); > > > - exit(1); > > > - } else { > > > - fprintf(stderr, "UFFDIO_ZEROPAGE error %Ld\n", > > > - uffdio_zeropage.zeropage); > > > - exit(1); > > > - } > > > + uffd_error(uffdio_zeropage.zeropage == -EEXIST ? > > > + "UFFDIO_ZEROPAGE -EEXIST" : > > > + "UFFDIO_ZEROPAGE error", > > > > Nit: The indents here are a bit odd.. > > This is what clang-format yields. Are you thinking it would be better > to line everything up with the ( in uffd_error( ? > > Or, perhaps this case is a good reason to make uffd_error() a variadic > macro so we can insert "-EEXIST" || "error" with a "%s". Yes. It fixes a build warning, so I think current patch is fine too. No matter whether you'd like a v2, please feel free to take: Acked-by: Peter Xu Thanks, -- Peter Xu