From patchwork Sun Nov 21 22:14:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 47981 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB27E3858411 for ; Sun, 21 Nov 2021 22:14:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB27E3858411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637532865; bh=R3vHZgXN0AFEtbIWtN4PJXjzO5kFdEzFopJlEurs94k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=k1mkPwU+mAXWD2tLyUwNnM1repL61jPRZiv+YAhqO5iL8AHj4p82lOFiImhLVZlGZ GJ0H8IFmSzrudtGBRg9Xb74G1J2plUPr1au+FBjNu/59OhE2fg28T9rX03tnwJN78P 0kLDOFFGS0dDxAH5tpftI7WvCk2PgNx8ciWdS83A= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 9B73D3858C3A for ; Sun, 21 Nov 2021 22:14:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B73D3858C3A Received: by mail-wr1-x42e.google.com with SMTP id a9so29093073wrr.8 for ; Sun, 21 Nov 2021 14:14:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R3vHZgXN0AFEtbIWtN4PJXjzO5kFdEzFopJlEurs94k=; b=jCNYkNBT6gp3d7ysc6M2ooXBUQmS5xThQY9reDoF1sVtnDSFbCwK6ADHO1KbhufhuW /aGpQqqoRzVtNt9ftbvzAMm05W7XR9djcyUjoQ7Y32RYO4SG+OrpBN9c3LDybPGH+q6W mTysRbpfhYD2XCMVorLnuw/5KrZ9PDqDHN/83DgegoWbUPiMZZKL+x9Lq7MGWOPovydB QCQ791tSrGzrUt2Ikq3vT0rIcScnChuMZKWZfbyaJHCa6R8cVUmUaxPBafdnpUQWzZDa 7/I0G/zsLG45Gd7NdOpS6ASy5KoEMf56P+/SJu+4gu+JpvbHa+4LI1zFwVO6kLDt79X2 RWvQ== X-Gm-Message-State: AOAM531XI0EjXjVpoLKxCWIPu5ANlQnwYpMbSC7tSyLsQ3gqPp7kMW0E 6m0QkrC959TYWmKeX8ayLeU= X-Google-Smtp-Source: ABdhPJwyJcG5CRIXaOYI1/h6kj84yCJXxXBSjZPwqBfVlLFRS0yKTEsS9Q9h2UZCAD/DlQvysiuWcQ== X-Received: by 2002:a5d:58c5:: with SMTP id o5mr31858592wrf.15.1637532855716; Sun, 21 Nov 2021 14:14:15 -0800 (PST) Received: from nereus.lab.linutronix.de. (b2b-109-90-143-203.unitymedia.biz. [109.90.143.203]) by smtp.gmail.com with ESMTPSA id t127sm20706817wma.9.2021.11.21.14.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 14:14:15 -0800 (PST) X-Google-Original-From: Alexander Kanavin To: mark@klomp.org, elfutils-devel@sourceware.org Subject: [PATCH] debuginfod/debuginfod-client.c: correct string format on 32bit arches with 64bit time_t Date: Sun, 21 Nov 2021 23:14:11 +0100 Message-Id: <20211121221411.404194-1-alex@linutronix.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexander Kanavin via Elfutils-devel From: Alexander Kanavin Reply-To: Alexander Kanavin Cc: Alexander Kanavin , Khem Raj Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" From: Alexander Kanavin Use intmax_t to print time_t time_t is platform dependent and some of architectures e.g. x32, riscv32, arc use 64bit time_t even while they are 32bit architectures, therefore directly using integer printf formats will not work portably, use intmax_t to typecast time_t into printf family of functions. musl 1.2.0 and above uses time64 on all platforms; glibc 2.34 has added support for time64 (which might be enabled by distro-wide CFLAGS), with possibly 2.35 or 2.36 making it enabled by default. Use a plain int for scanning cache_config, as that's what the function returns. Signed-off-by: Alexander Kanavin Signed-off-by: Khem Raj --- debuginfod/debuginfod-client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index c875ee62..df9737d2 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -231,15 +231,15 @@ debuginfod_config_cache(char *config_path, if (fd < 0) return -errno; - if (dprintf(fd, "%ld", cache_config_default_s) < 0) + if (dprintf(fd, "%jd", (intmax_t)cache_config_default_s) < 0) return -errno; } - long cache_config; + int cache_config; FILE *config_file = fopen(config_path, "r"); if (config_file) { - if (fscanf(config_file, "%ld", &cache_config) != 1) + if (fscanf(config_file, "%d", &cache_config) != 1) cache_config = cache_config_default_s; fclose(config_file); } @@ -272,7 +272,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path) if (fd < 0) return -errno; - if (dprintf(fd, "%ld", cache_clean_default_interval_s) < 0) + if (dprintf(fd, "%jd", (intmax_t)cache_clean_default_interval_s) < 0) return -errno; /* init max age config file. */ @@ -280,7 +280,7 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path) && (fd = open(maxage_path, O_CREAT | O_RDWR, DEFFILEMODE)) < 0) return -errno; - if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0) + if (dprintf(fd, "%jd", (intmax_t)cache_default_max_unused_age_s) < 0) return -errno; return 0;