From patchwork Tue Dec 10 09:10:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 11281739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC8B913B6 for ; Tue, 10 Dec 2019 09:11:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C776920726 for ; Tue, 10 Dec 2019 09:11:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="n3BqRzW3"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G3Ih9QEP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C776920726 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 741B085D; Tue, 10 Dec 2019 10:10:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 741B085D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1575969108; bh=L2VzLtar9rm0nn5PwGBDh56j4XQGzPs5BxGJcV+qv1A=; h=From:To:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=n3BqRzW3N0Tar6rUgOjrL05DxUqNqG7DGCJLPYKrwBsJo4I3hXmzkIg8PeCF+rzVH p5xvdG3jddhMPcfX1Yddgp6xA6NRZWv/8kX3Z1F6GK4zegyDDY/FDs05JwLcmSdvD+ uWDOQmCCrDe+t+tj3r/3QtmfMgJrMSIdWY/6tM9A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 803EFF80217; Tue, 10 Dec 2019 10:10:57 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 88D96F80248; Tue, 10 Dec 2019 10:10:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 28903F800F3 for ; Tue, 10 Dec 2019 10:10:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 28903F800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G3Ih9QEP" Received: by mail-pj1-x102b.google.com with SMTP id ca19so7149612pjb.8 for ; Tue, 10 Dec 2019 01:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=iAka9PCMzUV/Go882dsW2XBzBH2WGkc6IRilMYRAjgo=; b=G3Ih9QEPSbEpVAuWFDLlWEsfT7xtnE3GtpH4yX+kxJdRtzEcm9l30AMSDOWAhZgbes cz9uOWicu+fWi2cwBTRKulbfqOdN0RCaz4+yRO09mjfSyZTf7vBGNtx8D1WV9REh72eR dq1bPKuXCa0i5isedk6GFqZMRSaP+/QHwGj/axfkpXzhm8vvVVJZT291PRQfPXya8Uhp xdaXQphaMVa5jTfp10inWB8dzJuT8fSvPlAShCF8NWU+rTtisSi7td3E8CI9E2DPO15a AszQI7gW9CBgNzCDi1GM+/aN62TwM1mcr2IJVWezK7tBBtJfCWvCJeJXxIy6aM22mBqY nIDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=iAka9PCMzUV/Go882dsW2XBzBH2WGkc6IRilMYRAjgo=; b=q6okBgss8B7CrTCmNhG1GIa7sLLIq7Kl2hu0oNVCbxoZOjpvqY5Fe56z2HJHvK49m4 sXu0d+fWsi1VTelS9J/Gci56GG+Ab4cUjP4Php2xRijiFEc/Bzw8JsuhmhvplN90QyKD TXWyBlsn4GCjXZDgpqhXGZr9h3ZkXxEb/WQZRMFVpaudB04hiZSGD5ra9Xe5hmgLF3Vv xXa6IpgMYsk5T71YJlXUQQL1p+vRX1/iHJzf+hO1O5ykIt661c8jVte0PwqhStKuldgl TTKRZeYOWu1iLiVVyxPAE4fQQ8puP8kyqHHrtOIj9qtvedDRALPvE4oeg+h+JTsfxh3H TTnA== X-Gm-Message-State: APjAAAWRhnvsVDdBynZ1blX1yP49PAe4xzFwVnkeDwSGWNkwctzybFqi Tg7IbrDlrrsK5H7ObKB30v961urwddo= X-Google-Smtp-Source: APXvYqx52rM2c19cP0n4NS72e9CFFlckMO2mFJo84WTv4/lNLGYAnujm1oBJTMo+3EqCY8zpKy7Sfw== X-Received: by 2002:a17:90a:a004:: with SMTP id q4mr4228578pjp.106.1575969049469; Tue, 10 Dec 2019 01:10:49 -0800 (PST) Received: from localhost.localdomain ([69.42.0.214]) by smtp.gmail.com with ESMTPSA id d14sm2140551pjz.12.2019.12.10.01.10.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 01:10:48 -0800 (PST) From: Rosen Penev To: alsa-devel@alsa-project.org Date: Tue, 10 Dec 2019 01:10:45 -0800 Message-Id: <20191210091047.143081-1-rosenp@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [alsa-devel] [PATCH 1/3] treewide: Fix -Wformat=2 warnings X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Allows the compiler to check these formats at compile time. Fixed several such warnings. Signed-off-by: Rosen Penev --- include/use-case.h | 1 + src/error.c | 2 ++ src/input.c | 6 ++++-- src/output.c | 6 ++++-- src/pcm/pcm.c | 4 ++-- src/pcm/pcm_direct.c | 2 +- src/pcm/pcm_file.c | 6 +++--- src/topology/builder.c | 3 ++- src/ucm/ucm_local.h | 2 ++ 9 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/use-case.h b/include/use-case.h index 2efcb4d8..3f0cf58e 100644 --- a/include/use-case.h +++ b/include/use-case.h @@ -188,6 +188,7 @@ typedef struct snd_use_case_mgr snd_use_case_mgr_t; * \param ... Optional arguments for sprintf like format * \return Allocated string identifier or NULL on error */ +__attribute__((format(printf, 1, 2))) char *snd_use_case_identifier(const char *fmt, ...); /** diff --git a/src/error.c b/src/error.c index 2e617f87..ad281411 100644 --- a/src/error.c +++ b/src/error.c @@ -95,6 +95,7 @@ snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func * \ref snd_lib_error_set_local, it is called. Otherwise, prints the error * message including location to \c stderr. */ +__attribute__((format(printf, 5, 6))) static void snd_lib_error_default(const char *file, int line, const char *function, int err, const char *fmt, ...) { va_list arg; @@ -149,6 +150,7 @@ const char *snd_asoundlib_version(void) /* * internal error handling */ +__attribute__((format(printf, 5, 6))) static void snd_err_msg_default(const char *file, int line, const char *function, int err, const char *fmt, ...) { va_list arg; diff --git a/src/input.c b/src/input.c index 35324f1f..c204fe7b 100644 --- a/src/input.c +++ b/src/input.c @@ -132,6 +132,7 @@ static int snd_input_stdio_close(snd_input_t *input ATTRIBUTE_UNUSED) return 0; } +__attribute__((format(scanf, 2, 0))) static int snd_input_stdio_scan(snd_input_t *input, const char *format, va_list args) { snd_input_stdio_t *stdio = input->private_data; @@ -144,7 +145,7 @@ static char *snd_input_stdio_gets(snd_input_t *input, char *str, size_t size) snd_input_stdio_t *stdio = input->private_data; return fgets(str, (int) size, stdio->fp); } - + static int snd_input_stdio_getc(snd_input_t *input) { snd_input_stdio_t *stdio = input->private_data; @@ -236,6 +237,7 @@ static int snd_input_buffer_close(snd_input_t *input) return 0; } +__attribute__((format(scanf, 2, 0))) static int snd_input_buffer_scan(snd_input_t *input, const char *format, va_list args) { snd_input_buffer_t *buffer = input->private_data; @@ -262,7 +264,7 @@ static char *snd_input_buffer_gets(snd_input_t *input, char *str, size_t size) *str = '\0'; return str; } - + static int snd_input_buffer_getc(snd_input_t *input) { snd_input_buffer_t *buffer = input->private_data; diff --git a/src/output.c b/src/output.c index 7e3a91b3..935ab003 100644 --- a/src/output.c +++ b/src/output.c @@ -141,6 +141,7 @@ static int snd_output_stdio_close(snd_output_t *output) return 0; } +__attribute__((format(printf, 2, 0))) static int snd_output_stdio_print(snd_output_t *output, const char *format, va_list args) { snd_output_stdio_t *stdio = output->private_data; @@ -152,7 +153,7 @@ static int snd_output_stdio_puts(snd_output_t *output, const char *str) snd_output_stdio_t *stdio = output->private_data; return fputs(str, stdio->fp); } - + static int snd_output_stdio_putc(snd_output_t *output, int c) { snd_output_stdio_t *stdio = output->private_data; @@ -268,6 +269,7 @@ static int snd_output_buffer_need(snd_output_t *output, size_t size) return buffer->alloc - buffer->size; } +__attribute__((format(printf, 2, 0))) static int snd_output_buffer_print(snd_output_t *output, const char *format, va_list args) { snd_output_buffer_t *buffer = output->private_data; @@ -304,7 +306,7 @@ static int snd_output_buffer_puts(snd_output_t *output, const char *str) buffer->size += size; return size; } - + static int snd_output_buffer_putc(snd_output_t *output, int c) { snd_output_buffer_t *buffer = output->private_data; diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 1064044c..09dfe967 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -8241,7 +8241,7 @@ int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf) return -ENOMEM; } if (map->pos[i] & SND_CHMAP_DRIVER_SPEC) - len += snprintf(buf + len, maxlen - len, "%d", p); + len += snprintf(buf + len, maxlen - len, "%u", p); else { const char *name = chmap_names[p]; if (name) @@ -8249,7 +8249,7 @@ int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf) "%s", name); else len += snprintf(buf + len, maxlen - len, - "Ch%d", p); + "Ch%u", p); } if (len >= maxlen) return -ENOMEM; diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 54d99005..719e1692 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -1406,7 +1406,7 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix) SNDERR("unable to info for slave pcm"); return ret; } - sprintf(name, "hw:CLASS=%i,SCLASS=0,CARD=%i,DEV=%i,SUBDEV=%i", + sprintf(name, "hw:CLASS=%i,SCLASS=0,CARD=%i,DEV=%u,SUBDEV=%u", (int)SND_TIMER_CLASS_PCM, snd_pcm_info_get_card(&info), snd_pcm_info_get_device(&info), diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index a02b2dc0..c874e863 100644 --- a/src/pcm/pcm_file.c +++ b/src/pcm/pcm_file.c @@ -155,7 +155,7 @@ static int snd_pcm_file_replace_fname(snd_pcm_file_t *file, char **new_fname_p) next char */ switch (*(++old_index_ch)) { case RATE_KEY: - snprintf(value, sizeof(value), "%d", + snprintf(value, sizeof(value), "%u", pcm->rate); err = snd_pcm_file_append_value(&new_fname, &new_index_ch, &new_len, value); @@ -164,7 +164,7 @@ static int snd_pcm_file_replace_fname(snd_pcm_file_t *file, char **new_fname_p) break; case CHANNELS_KEY: - snprintf(value, sizeof(value), "%d", + snprintf(value, sizeof(value), "%u", pcm->channels); err = snd_pcm_file_append_value(&new_fname, &new_index_ch, &new_len, value); @@ -173,7 +173,7 @@ static int snd_pcm_file_replace_fname(snd_pcm_file_t *file, char **new_fname_p) break; case BWIDTH_KEY: - snprintf(value, sizeof(value), "%d", + snprintf(value, sizeof(value), "%u", pcm->frame_bits/pcm->channels); err = snd_pcm_file_append_value(&new_fname, &new_index_ch, &new_len, value); diff --git a/src/topology/builder.c b/src/topology/builder.c index 5ae3ae89..3adbad45 100644 --- a/src/topology/builder.c +++ b/src/topology/builder.c @@ -21,6 +21,7 @@ #include "tplg_local.h" /* verbose output detailing each object size and file position */ +__attribute__((format(printf, 2, 3))) static void verbose(snd_tplg_t *tplg, const char *fmt, ...) { int offset; @@ -244,7 +245,7 @@ static int write_manifest_data(snd_tplg_t *tplg) return ret; } - verbose(tplg, "manifest : write %d bytes\n", sizeof(tplg->manifest)); + verbose(tplg, "manifest : write %zu bytes\n", sizeof(tplg->manifest)); ret = write(tplg->out_fd, &tplg->manifest, sizeof(tplg->manifest)); if (ret < 0) { SNDERR("error: failed to write manifest %d\n", ret); diff --git a/src/ucm/ucm_local.h b/src/ucm/ucm_local.h index ba961507..696a60dc 100644 --- a/src/ucm/ucm_local.h +++ b/src/ucm/ucm_local.h @@ -246,7 +246,9 @@ struct snd_use_case_mgr { #define uc_dbg(fmt, arg...) do { } while (0) #endif +__attribute__((format(printf, 1, 2))) void uc_mgr_error(const char *fmt, ...); +__attribute__((format(printf, 1, 2))) void uc_mgr_stdout(const char *fmt, ...); int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg); From patchwork Tue Dec 10 09:10:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 11281741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C85613B6 for ; Tue, 10 Dec 2019 09:12:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 254FE206E0 for ; Tue, 10 Dec 2019 09:12:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="YKXh6lIC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LIheWze8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 254FE206E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6D6821666; Tue, 10 Dec 2019 10:11:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6D6821666 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1575969168; bh=rM4MU5l+MH/8WQM2LPiULoqpHSfSnV4L7rPgYlUDY/Q=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YKXh6lICD3P+WLvNDYmfMnHUM6anFGpfnEaaNxfz/D7esXK3/yQlt+sy5aWda0SPK XuWfCbAHOaN0OdcVGnutc3BlyxKluzYTOgqDNu6EeuIYLZAGaeQiRQsEU1pEYUXmvE ZMSCXprLvBM7YvOqK3SvT79o9fztqvXRm8cTRnJo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F2269F80257; Tue, 10 Dec 2019 10:11:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3868EF8024A; Tue, 10 Dec 2019 10:10:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D6693F801D8 for ; Tue, 10 Dec 2019 10:10:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D6693F801D8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LIheWze8" Received: by mail-pf1-x443.google.com with SMTP id h14so8731009pfe.10 for ; Tue, 10 Dec 2019 01:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/2bb85NdiLVYQHcFIrkxh6hcV2+mLDZuC89mTaxdlY0=; b=LIheWze8tbYJDsMbadKe3DsTV+4N3yyJWAvlHK+8/SC/KqUeg0tMNtXW02MDDOuZXw bmHuhCcoU8+0HAFdFvIXF4G0HSxYi8Fu7Y0pWHyPI7Mj4kA6kncA30LmUJhzpunQ0SyN d0HvfPPrNr7mpWA6Mtq8kvA8NpNko4egWlmDIqU/Vd5V8i4v/VWSfJKrAe1kkP8Ki6i3 pHeG8fAxeWK7OKtUaFCjKeQYiyEPQ/GWAqxebxGsABr1yP9LtI/xW9A6qgE486sPqA5M uJVfiBEz1wx1DmeYIyvX9ZF5pwp116FW5K3Wku+byQAHFuFLup+y0PF780F72rlUOVb5 cHdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/2bb85NdiLVYQHcFIrkxh6hcV2+mLDZuC89mTaxdlY0=; b=eTbtEWnfKRPRmRXc/Hlp4gFccIk4wKOCyERiBpdKJVC8AijcyiXsiu8/KlzeDcenjS Sc2M5OP3kN7W9IPceVuFa3t0e/Gku7GVCkX7zOYPI4fB8kRWOCE6PDnuAPhxf14v+ME8 kDEwfXva4ZU+aoWUskRyO7amzSYT8dembWZ8mdTZ+sk5IKzpM43PMcib+xN9nd2P6F8a mWi+mUH1gq7hryovUyyzoqMmj8B+WV3Mg7y5LVvqsV2wavcqouI/o1WOvJTkWoPH/RBM vVPJ/NRiwKTQTBjrLCWQyLfGiHlGQbyIObjBSvdUoKZuxif3+FgHX5jlF0Ue5q7BYI0U IXxA== X-Gm-Message-State: APjAAAUcKu8LNqAHMUb8KusvwsDsq3+J2mRxWlR34WTBU5iDgFv2aHGW T7hHHKId8N4WLPLiifqE+k2bJhDGJws= X-Google-Smtp-Source: APXvYqx7lu59NgGKrpzMGjUrwf9Ly2xTpuj0urQbNrkKFRsc7eVpDY1AhiPxBHAiGUExo9RaMG86SQ== X-Received: by 2002:a63:d041:: with SMTP id s1mr23809454pgi.363.1575969050886; Tue, 10 Dec 2019 01:10:50 -0800 (PST) Received: from localhost.localdomain ([69.42.0.214]) by smtp.gmail.com with ESMTPSA id d14sm2140551pjz.12.2019.12.10.01.10.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 01:10:49 -0800 (PST) From: Rosen Penev To: alsa-devel@alsa-project.org Date: Tue, 10 Dec 2019 01:10:46 -0800 Message-Id: <20191210091047.143081-2-rosenp@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191210091047.143081-1-rosenp@gmail.com> References: <20191210091047.143081-1-rosenp@gmail.com> MIME-Version: 1.0 Subject: [alsa-devel] [PATCH 2/3] topology/builder: Fix absolute value warning X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" next_hdr_pos is unsigned and promotes offset as such. This makes the abs call useless. Changed the abs call to labs and the offset to off_t to avoid this. Signed-off-by: Rosen Penev --- src/topology/builder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/topology/builder.c b/src/topology/builder.c index 3adbad45..98956dac 100644 --- a/src/topology/builder.c +++ b/src/topology/builder.c @@ -45,7 +45,7 @@ static int write_block_header(snd_tplg_t *tplg, unsigned int type, { struct snd_soc_tplg_hdr hdr; size_t bytes; - int offset = lseek(tplg->out_fd, 0, SEEK_CUR); + off_t offset = lseek(tplg->out_fd, 0, SEEK_CUR); memset(&hdr, 0, sizeof(hdr)); hdr.magic = SND_SOC_TPLG_MAGIC; @@ -64,7 +64,7 @@ static int write_block_header(snd_tplg_t *tplg, unsigned int type, " offset 0x%x is %s by %d bytes\n", tplg->next_hdr_pos, offset, (unsigned int)offset > tplg->next_hdr_pos ? "ahead" : "behind", - abs(offset - tplg->next_hdr_pos)); + labs(offset - (off_t)tplg->next_hdr_pos)); exit(-EINVAL); } From patchwork Tue Dec 10 09:10:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 11281743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CA6A138D for ; Tue, 10 Dec 2019 09:13:35 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 056B52073D for ; Tue, 10 Dec 2019 09:13:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Z41lSQIm"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LX9RKscH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 056B52073D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3A5C186F; Tue, 10 Dec 2019 10:12:43 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3A5C186F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1575969213; bh=onjxU1gYxPOoR5ZR9xkpWOZ8sJll4HJgVIkryk45cbw=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Z41lSQImohNX6fYfK9aW+HhyB0vs4/j6sNouc0RjwRIOrtETfOuL1pg2m+0flO/Sp +teP2nlpvkxphZA1gesSk65XKXk62oQHzJf/tOsosNUF8mqZGT4zFv9xaJYFybcyeP aIIB+5b6/P9+fCAy8HZStqi6vfGQ3lipPaN8ZGjM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2853BF8025F; Tue, 10 Dec 2019 10:11:03 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id B23C3F80252; Tue, 10 Dec 2019 10:10:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E0801F8020C for ; Tue, 10 Dec 2019 10:10:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E0801F8020C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LX9RKscH" Received: by mail-pf1-x444.google.com with SMTP id s18so8738688pfd.8 for ; Tue, 10 Dec 2019 01:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fxz/ONsrqU9P66QbwRL+UbxSqwXSyA4HCqEno4y3b3A=; b=LX9RKscHDCBjY60HqM3uqx6NFfisCSukdCEyHhOgNBVOgHhlYTVT5zBkx4SCPsweyX SYZSn0M/dJX4OHV8Rcj1lIMvuiTgg5VQbrFR6OtXZqUy8I67vyuQu3KqqD7URsAvIFMJ 5maza1XagQXHtACV4+Dz8h1HrjUfdA1Cj3Fslg7XY3ZgZjinQxNugDu9/PA9BrDxcZ26 XN5KWlj0oDw6RWuOCEOJFLTdLFTY1HHFeuDPjdUfhgBUtGxyrn/8Jy/FR+s4OPD/IaGM cBXq/Es8506M1XTXGfJjh8mH+jiU8ES2n/zib1HkYkf5YIuQPHUN1s10LW/+xUEkGuyM p/lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fxz/ONsrqU9P66QbwRL+UbxSqwXSyA4HCqEno4y3b3A=; b=di43nrXAXKvPsik9Th5738pqEwjVhMpdhCAtkBfWIbg4VFaFfNUHwGQkmBWWdYQFj/ d2ZlvUCIH9wu/E6uFuJ50tluBhPAjMkOWXwrG3fHlSHrtyU9zi+BGGOecLq0iB7D+t05 U74Ww/7kaTyo+/8/UwyirhgunU8V/QifsbVJmI7Rjrn2nPRSdgR/950N0vBPyXLv9mky a3J9/gIBnAHIyEqdVc9wqToThiKzRB5WJ74vV/8JXVW+3QK9oXOKx8cT0ksQpC/MjWMx N4sov1Dno5G7HBCx22O7i6KIZXEWMLDNVQjCyKRH4eT8dpTgg/ennNmKXL/4Ow+/Gnzs sfkw== X-Gm-Message-State: APjAAAVxD8/xA3bpNcB7EqeYz5Y++awfE2ZOdMM82p2KUOZIPv8X1eGd ANTWA2dCUm+2+zHq1ztmETOsA38rPFU= X-Google-Smtp-Source: APXvYqzXPt1mIMkUWG0Q2dt7ouQjjmCUT0KOAmVjplg09OYBfX5bB44SqngMowyhaBvQq2TZcYdg/Q== X-Received: by 2002:a63:f551:: with SMTP id e17mr23164448pgk.162.1575969051777; Tue, 10 Dec 2019 01:10:51 -0800 (PST) Received: from localhost.localdomain ([69.42.0.214]) by smtp.gmail.com with ESMTPSA id d14sm2140551pjz.12.2019.12.10.01.10.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 01:10:51 -0800 (PST) From: Rosen Penev To: alsa-devel@alsa-project.org Date: Tue, 10 Dec 2019 01:10:47 -0800 Message-Id: <20191210091047.143081-3-rosenp@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191210091047.143081-1-rosenp@gmail.com> References: <20191210091047.143081-1-rosenp@gmail.com> MIME-Version: 1.0 Subject: [alsa-devel] [PATCH 3/3] treewide: Remove extra ; warning X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Enclosed defines in a do/while loop to silence this. Signed-off-by: Rosen Penev --- src/conf.c | 20 ++++++++++---------- src/mixer/simple.c | 16 ++++++++-------- src/topology/parser.c | 2 +- src/ucm/ucm_subs.c | 10 ++++++---- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/conf.c b/src/conf.c index e4306504..c26999b0 100644 --- a/src/conf.c +++ b/src/conf.c @@ -3062,7 +3062,7 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) #ifndef DOC_HIDDEN #define SND_CONFIG_SEARCH(config, key, result, extra_code) \ -{ \ +do { \ snd_config_t *n; \ int err; \ const char *p; \ @@ -3081,10 +3081,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) } else \ return _snd_config_search(config, key, -1, result); \ } \ -} +} while(0) #define SND_CONFIG_SEARCHA(root, config, key, result, fcn, extra_code) \ -{ \ +do { \ snd_config_t *n; \ int err; \ const char *p; \ @@ -3108,10 +3108,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) } else \ return _snd_config_search(config, key, -1, result); \ } \ -} +} while(0) #define SND_CONFIG_SEARCHV(config, result, fcn) \ -{ \ +do { \ snd_config_t *n; \ va_list arg; \ assert(config); \ @@ -3132,10 +3132,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) if (result) \ *result = n; \ return 0; \ -} +} while(0) #define SND_CONFIG_SEARCHVA(root, config, result, fcn) \ -{ \ +do { \ snd_config_t *n; \ va_list arg; \ assert(config); \ @@ -3156,10 +3156,10 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) if (result) \ *result = n; \ return 0; \ -} +} while(0) #define SND_CONFIG_SEARCH_ALIAS(config, base, key, result, fcn1, fcn2) \ -{ \ +do { \ snd_config_t *res = NULL; \ char *old_key; \ int err, first = 1, maxloop = 1000; \ @@ -3201,7 +3201,7 @@ int snd_config_save(snd_config_t *config, snd_output_t *out) if (result) \ *result = res; \ return 0; \ -} +} while(0) #endif /* DOC_HIDDEN */ diff --git a/src/mixer/simple.c b/src/mixer/simple.c index 2861d97c..2b9daa6e 100644 --- a/src/mixer/simple.c +++ b/src/mixer/simple.c @@ -82,30 +82,30 @@ int snd_mixer_selem_register(snd_mixer_t *mixer, #ifndef DOC_HIDDEN #define CHECK_BASIC(xelem) \ -{ \ +do { \ assert(xelem); \ assert((xelem)->type == SND_MIXER_ELEM_SIMPLE); \ -} +} while(0) #define CHECK_DIR(xelem, xwhat) \ -{ \ +do { \ unsigned int xcaps = ((sm_selem_t *)(elem)->private_data)->caps; \ if (! (xcaps & (xwhat))) \ return -EINVAL; \ -} +} while(0) #define CHECK_DIR_CHN(xelem, xwhat, xjoin, xchannel) \ -{ \ +do { \ unsigned int xcaps = ((sm_selem_t *)(elem)->private_data)->caps; \ if (! (xcaps & (xwhat))) \ return -EINVAL; \ if (xcaps & (xjoin)) \ xchannel = 0; \ -} +} while(0) -#define CHECK_ENUM(xelem) \ +#define CHECK_ENUM(xelem) do { \ if (!(((sm_selem_t *)(elem)->private_data)->caps & (SM_CAP_PENUM|SM_CAP_CENUM))) \ - return -EINVAL; + return -EINVAL; } while(0) #define COND_CAPS(xelem, what) \ !!(((sm_selem_t *)(elem)->private_data)->caps & (what)) diff --git a/src/topology/parser.c b/src/topology/parser.c index 5940692d..473a65e6 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -382,7 +382,7 @@ int snd_tplg_add_object(snd_tplg_t *tplg, snd_tplg_obj_template_t *t) default: SNDERR("error: invalid object type %d\n", t->type); return -EINVAL; - }; + } } int snd_tplg_build(snd_tplg_t *tplg, const char *outfile) diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c index 90e395f0..5d5fd64e 100644 --- a/src/ucm/ucm_subs.c +++ b/src/ucm/ucm_subs.c @@ -146,15 +146,16 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char return strdup(path); } -#define MATCH_VARIABLE(name, id, fcn, empty_ok) \ +#define MATCH_VARIABLE(name, id, fcn, empty_ok) do { \ if (strncmp((name), (id), sizeof(id) - 1) == 0) { \ rval = fcn(uc_mgr); \ idsize = sizeof(id) - 1; \ allow_empty = (empty_ok); \ goto __rval; \ - } + } \ +} while(0) -#define MATCH_VARIABLE2(name, id, fcn) \ +#define MATCH_VARIABLE2(name, id, fcn) do { \ if (strncmp((name), (id), sizeof(id) - 1) == 0) { \ idsize = sizeof(id) - 1; \ tmp = strchr(value + idsize, '}'); \ @@ -170,7 +171,8 @@ static char *rval_sysfs(snd_use_case_mgr_t *uc_mgr ATTRIBUTE_UNUSED, const char rval = fcn(uc_mgr, v2); \ goto __rval; \ } \ - } + } \ +} while(0) int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr, char **_rvalue,