From patchwork Fri Nov 19 18:15:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 47945 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 AD6DD3858418 for ; Fri, 19 Nov 2021 18:15:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD6DD3858418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1637345744; bh=uy0OZLMXInuTzKE9lkvWzwNah577SyX128teVD5euWY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=LphGO/k+dpfaHcsvaLGmSJKYdxCmwf3S5U4+dbkwgFx0aLMLSzec0gLRR13+e4kyK OLYg+HRn2BVSAFW365hTPEF5vcb3rg7DXHxu+7SOe2RRxSw/0gHS08uasP+LswRMQO Pv6wVWtorK+a6Hc/3dX2x/iV2ydQzhz24aG+G0sQ= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 4542D385840D for ; Fri, 19 Nov 2021 18:15:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4542D385840D Received: by mail-wr1-x42b.google.com with SMTP id c4so19546800wrd.9 for ; Fri, 19 Nov 2021 10:15:35 -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=uy0OZLMXInuTzKE9lkvWzwNah577SyX128teVD5euWY=; b=e8979GS/QhfD980BVCUp/TvXdiqhZtA3nTlkcv4WhY8sPW/2LlP4b3hHsB9LpqkZP7 wF/ORfloJktIr3hZxErY7MfJeMOYmPg3R0+dvNPB4pkuZZlwwOeC7MAiu0l+CEEZ3wpH JN+RedvxTY9SQzJLJRHOlRuuHsFQDpiI6OQa1/Gys5gG+sa0aonKxcb6eDO1CvdzSATc rorpOmJ83zZJRmsE+wDTYZ0+m/j/TOgIXxsFB0g891ojJogGAFJVu9s8LgYow0Cbiaq5 nnJGxcNKpIsAGfAQE+jySVTHericX3KxAi7sGYbITbm71qYDucFBbbEyyB5gtgKxbigg BN/g== X-Gm-Message-State: AOAM531r8wGmM1ossg20z+XZhyRqBari1zBV1IJaSTpaqqQkR4UbRKXg cFyagySQI3f+dEcHy8bM8PY= X-Google-Smtp-Source: ABdhPJx/5JRk5J37/fgr1vL2Q/KktyzOTkjow1Cw7dvitrVbhIl3FTV8TWZ+FwOaB3PQIcTX49GVwQ== X-Received: by 2002:adf:fb86:: with SMTP id a6mr9592517wrr.35.1637345734350; Fri, 19 Nov 2021 10:15:34 -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 t9sm485074wrx.72.2021.11.19.10.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 10:15:33 -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: Fri, 19 Nov 2021 19:15:24 +0100 Message-Id: <20211119181524.3190417-1-alex@linutronix.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 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 Signed-off-by: Alexander Kanavin Signed-off-by: Khem Raj --- debuginfod/debuginfod-client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index c875ee62..afd223b3 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -231,7 +231,7 @@ 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; } @@ -239,7 +239,7 @@ debuginfod_config_cache(char *config_path, FILE *config_file = fopen(config_path, "r"); if (config_file) { - if (fscanf(config_file, "%ld", &cache_config) != 1) + if (fscanf(config_file, "%jd", (intmax_t*)(&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;