linux-nfc.lists.01.org archive mirror
 help / color / mirror / Atom feed
* [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued)
@ 2021-07-11 20:20 Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 01/34] Drop empty NEWS Krzysztof Kozlowski
                   ` (33 more replies)
  0 siblings, 34 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Hi,

I continued with the fixes and CI for neard, on top of my previous
patchset:
https://lore.kernel.org/linux-nfc/20210710033859.3989-1-krzysztof.kozlowski@canonical.com/T/#t

Except compiler fixes, extend also Continuous Integration with
additional build configurations (i686, cross compile).  Explicitly run
also unit tests although they do not cover much of the code.

The patchset is available on Github:
https://github.com/krzk/neard
branches dev-more-ci and dev-c-warnings

Best regards,
Krzysztof

Krzysztof Kozlowski (34):
  Drop empty NEWS
  ci: add building without maintainer options
  ci: be verbose when building
  ci: add more build configurations (Fedora, Alpine, Debian,
    cross-compile, i386)
  ci: run unit tests
  adapter: adjust indentation of continued arguments
  ci: display printenv
  HACKING: refine required packages
  nciattach: fix poll.h include location
  unit: use proper pointer to uint8_t in test_snep_read_recv_fragments()
  build: fix setting CFLAGS on dash shell (Alpine Linux)
  build: add more compiler warnings
  gdbus: do not shadow global 'pending' variable (-Wshadow)
  nciattach: do not shadow other local 'opt' variable (-Wshadow)
  unit: do not shadow global 'uri' variable (-Wshadow)
  nfctool: use proper format for integers (-Wformat)
  bluetooth: use proper format for integers (-Wformat)
  ndef: use proper format for integers (-Wformat)
  nfctype2: use proper format for integers (-Wformat)
  nfctype3: use proper format for integers (-Wformat)
  nfctype5: use proper format for integers (-Wformat)
  mifare: use proper format for integers (-Wformat)
  p2p: use proper format for integers (-Wformat)
  npp: use proper format for integers (-Wformat)
  adapter: use proper format for integers (-Wformat)
  device: use proper format for integers (-Wformat)
  manager: use proper format for integers (-Wformat)
  tag: use proper format for integers (-Wformat)
  netlink: use proper format for integers (-Wformat)
  se: use proper format for integers (-Wformat)
  ndef: use proper format for integers (-Wformat)
  unit: use proper format for integers (-Wformat)
  build: enable -Wshadow and -Wformat-signedness compiler warnings
  AUTHORS: Mention Krzysztof Kozlowski's contributions

 .github/workflows/ci.yml    | 210 +++++++++++++++++++++++++++++++++++-
 AUTHORS                     |   1 +
 HACKING                     |  24 +++--
 NEWS                        |   0
 accflags.m4                 |  44 ++++++++
 acinclude.m4                |  16 ---
 ci/alpine.sh                |  35 ++++++
 ci/debian.cross-compile.sh  |  40 +++++++
 ci/debian.i386.sh           |  31 ++++++
 ci/debian.sh                |  14 ++-
 ci/fedora.sh                |  33 ++++++
 ci/ubuntu.cross-compile.sh  |   1 +
 ci/ubuntu.i386.sh           |   1 +
 configure.ac                |   5 +-
 gdbus/object.c              |  22 ++--
 plugins/mifare.c            |   8 +-
 plugins/nfctype2.c          |  12 +--
 plugins/nfctype3.c          |   2 +-
 plugins/nfctype5.c          |   6 +-
 plugins/npp.c               |   2 +-
 plugins/p2p.c               |   4 +-
 se/ace.c                    |  34 +++---
 se/apdu.c                   |   8 +-
 se/plugins/nfc.c            |   8 +-
 se/plugins/tizen.c          |   2 +-
 se/se.c                     |   6 +-
 src/adapter.c               |  40 +++----
 src/bluetooth.c             |   4 +-
 src/device.c                |   6 +-
 src/manager.c               |   4 +-
 src/ndef.c                  |  12 +--
 src/netlink.c               |  16 +--
 src/tag.c                   |   8 +-
 tools/nciattach.c           |  10 +-
 tools/nfctool/adapter.c     |   4 +-
 tools/nfctool/llcp-decode.c |   4 +-
 tools/nfctool/main.c        |  20 ++--
 tools/nfctool/sniffer.c     |   2 +-
 unit/test-ndef-parse.c      |  12 +--
 unit/test-snep-read.c       |   8 +-
 40 files changed, 550 insertions(+), 169 deletions(-)
 delete mode 100644 NEWS
 create mode 100644 accflags.m4
 create mode 100755 ci/alpine.sh
 create mode 100755 ci/debian.cross-compile.sh
 create mode 100755 ci/debian.i386.sh
 create mode 100755 ci/fedora.sh
 create mode 120000 ci/ubuntu.cross-compile.sh
 create mode 120000 ci/ubuntu.i386.sh

-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 01/34] Drop empty NEWS
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 02/34] ci: add building without maintainer options Krzysztof Kozlowski
                   ` (32 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

There are no news.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 NEWS | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 NEWS

diff --git a/NEWS b/NEWS
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 02/34] ci: add building without maintainer options
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 01/34] Drop empty NEWS Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 03/34] ci: be verbose when building Krzysztof Kozlowski
                   ` (31 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Check also silent builds.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 .github/workflows/ci.yml | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fb322381e7f5..ecd0683f6c79 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -20,27 +20,43 @@ jobs:
           - container: "ubuntu:hirsute"
             env:
               CC: gcc
+              MODE: maintainer
 
           - container: "ubuntu:focal"
             env:
               CC: gcc
+              MODE: maintainer
+
+          - container: "ubuntu:focal"
+            env:
+              CC: gcc
+              MODE: no-maintainer
 
           - container: "ubuntu:bionic"
             env:
               CC: gcc
+              MODE: maintainer
 
           - container: "ubuntu:xenial"
             env:
               CC: gcc
+              MODE: maintainer
 
           # Ubuntu clang
           - container: "ubuntu:hirsute"
             env:
               CC: clang
+              MODE: maintainer
 
           - container: "ubuntu:focal"
             env:
               CC: clang
+              MODE: maintainer
+
+          - container: "ubuntu:focal"
+            env:
+              CC: clang
+              MODE: no-maintainer
 
     container:
       image: ${{ matrix.container }}
@@ -72,7 +88,19 @@ jobs:
         cat /proc/cmdline
 
     - name: Configure
-      run: ./bootstrap-configure
+      run: |
+        echo "Bootstraping in mode: $MODE"
+        if [ "$MODE" = "maintainer" ]; then
+          ./bootstrap-configure
+        else
+          ./bootstrap && \
+            ./configure \
+            --disable-systemd \
+            --prefix=/usr \
+            --enable-ese \
+            --sysconfdir=/etc \
+            --enable-tools
+        fi
 
     - name: Compile
       run: make -j$(nproc)
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 03/34] ci: be verbose when building
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 01/34] Drop empty NEWS Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 02/34] ci: add building without maintainer options Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 04/34] ci: add more build configurations (Fedora, Alpine, Debian, cross-compile, i386) Krzysztof Kozlowski
                   ` (30 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 .github/workflows/ci.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ecd0683f6c79..85821ee6617c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -91,11 +91,13 @@ jobs:
       run: |
         echo "Bootstraping in mode: $MODE"
         if [ "$MODE" = "maintainer" ]; then
-          ./bootstrap-configure
+          ./bootstrap-configure \
+            --disable-silent-rules
         else
           ./bootstrap && \
             ./configure \
             --disable-systemd \
+            --disable-silent-rules \
             --prefix=/usr \
             --enable-ese \
             --sysconfdir=/etc \
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 04/34] ci: add more build configurations (Fedora, Alpine, Debian, cross-compile, i386)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 03/34] ci: be verbose when building Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 05/34] ci: run unit tests Krzysztof Kozlowski
                   ` (29 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

The installation scripts were based on LTP project.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 .github/workflows/ci.yml   | 160 ++++++++++++++++++++++++++++++++++++-
 ci/alpine.sh               |  34 ++++++++
 ci/debian.cross-compile.sh |  40 ++++++++++
 ci/debian.i386.sh          |  31 +++++++
 ci/debian.sh               |  13 +--
 ci/fedora.sh               |  32 ++++++++
 ci/ubuntu.cross-compile.sh |   1 +
 ci/ubuntu.i386.sh          |   1 +
 8 files changed, 305 insertions(+), 7 deletions(-)
 create mode 100755 ci/alpine.sh
 create mode 100755 ci/debian.cross-compile.sh
 create mode 100755 ci/debian.i386.sh
 create mode 100755 ci/fedora.sh
 create mode 120000 ci/ubuntu.cross-compile.sh
 create mode 120000 ci/ubuntu.i386.sh

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 85821ee6617c..8160aada2042 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,45 +16,183 @@ jobs:
       fail-fast: false
       matrix:
         include:
-          # Ubuntu gcc
+          # Debian builds
+          # 32bit build
+          - container: "debian:stable"
+            env:
+              ARCH: i386
+              CC: gcc -m32
+              CROSS_COMPILE: i686-linux-gnu
+              VARIANT: i386
+              MODE: maintainer
+
+          # Debian cross compilation builds
+          - container: "debian:stable"
+            env:
+              ARCH: armel
+              CC: arm-linux-gnueabi-gcc
+              CROSS_COMPILE: arm-linux-gnueabi
+              VARIANT: cross-compile
+              MODE: maintainer
+
+          - container: "debian:stable"
+            env:
+              ARCH: arm64
+              CC: aarch64-linux-gnu-gcc
+              CROSS_COMPILE: aarch64-linux-gnu
+              VARIANT: cross-compile
+              MODE: maintainer
+
+          - container: "debian:stable"
+            env:
+              ARCH: ppc64el
+              CC: powerpc64le-linux-gnu-gcc
+              CROSS_COMPILE: powerpc64le-linux-gnu
+              VARIANT: cross-compile
+              MODE: maintainer
+
+          - container: "debian:stable"
+            env:
+              ARCH: s390x
+              CC: s390x-linux-gnu-gcc
+              CROSS_COMPILE: s390x-linux-gnu
+              VARIANT: cross-compile
+              MODE: maintainer
+
+          # Debian gcc
+          - container: "debian:stable"
+            env:
+              ARCH: x86-64
+              CC: gcc
+              MODE: maintainer
+
+          - container: "debian:stable"
+            env:
+              ARCH: x86-64
+              CC: gcc
+              MODE: no-maintainer
+
+          - container: "debian:testing"
+            env:
+              ARCH: x86-64
+              CC: gcc
+              MODE: maintainer
+
+          - container: "debian:testing"
+            env:
+              ARCH: x86-64
+              CC: gcc
+              MODE: no-maintainer
+
+          # Debian clang
+          - container: "debian:stable"
+            env:
+              ARCH: x86-64
+              CC: clang
+              MODE: maintainer
+
+          - container: "debian:stable"
+            env:
+              ARCH: x86-64
+              CC: clang
+              MODE: no-maintainer
+
+          - container: "debian:testing"
+            env:
+              ARCH: x86-64
+              CC: clang
+              MODE: maintainer
+
+          # musl (native)
+          - container: "alpine:latest"
+            env:
+              ARCH: x86-64
+              CC: gcc
+              MODE: maintainer
+
+          # Fedora
+          - container: "fedora:latest"
+            env:
+              ARCH: x86-64
+              CC: gcc
+              MODE: maintainer
+
+          - container: "fedora:latest"
+            env:
+              ARCH: x86-64
+              CC: gcc
+              MODE: no-maintainer
+
+          - container: "fedora:latest"
+            env:
+              ARCH: x86-64
+              CC: clang
+              MODE: maintainer
+
+          # Ubuntu 32bit builds: gcc and clang
           - container: "ubuntu:hirsute"
             env:
+              ARCH: i386
+              CC: gcc -m32
+              CROSS_COMPILE: i686-linux-gnu
+              VARIANT: i386
+              MODE: maintainer
+
+          - container: "ubuntu:focal"
+            env:
+              ARCH: i386
+              CC: gcc -m32
+              CROSS_COMPILE: i686-linux-gnu
+              VARIANT: i386
+              MODE: maintainer
+
+          # Ubuntu x86-64 gcc
+          - container: "ubuntu:hirsute"
+            env:
+              ARCH: x86-64
               CC: gcc
               MODE: maintainer
 
           - container: "ubuntu:focal"
             env:
+              ARCH: x86-64
               CC: gcc
               MODE: maintainer
 
           - container: "ubuntu:focal"
             env:
+              ARCH: x86-64
               CC: gcc
               MODE: no-maintainer
 
           - container: "ubuntu:bionic"
             env:
+              ARCH: x86-64
               CC: gcc
               MODE: maintainer
 
           - container: "ubuntu:xenial"
             env:
+              ARCH: x86-64
               CC: gcc
               MODE: maintainer
 
-          # Ubuntu clang
+          # Ubuntu x86-64 clang
           - container: "ubuntu:hirsute"
             env:
+              ARCH: x86-64
               CC: clang
               MODE: maintainer
 
           - container: "ubuntu:focal"
             env:
+              ARCH: x86-64
               CC: clang
               MODE: maintainer
 
           - container: "ubuntu:focal"
             env:
+              ARCH: x86-64
               CC: clang
               MODE: no-maintainer
 
@@ -107,8 +245,26 @@ jobs:
     - name: Compile
       run: make -j$(nproc)
 
+    - name: Check final binary
+      run: |
+        file src/neard
+        ARCH_CHECK="$ARCH"
+        case "$ARCH" in
+          armel) ARCH_CHECK="ARM, EABI";;
+          arm64) ARCH_CHECK="aarch64";;
+          i386) ARCH_CHECK="Intel 80386";;
+          ppc64el) ARCH_CHECK="64-bit PowerPC";;
+          s390x) ARCH_CHECK="IBM S/390";;
+          *) ARCH_CHECK="x86-64";;
+        esac
+        echo "Checking for built matching architecture: $ARCH_CHECK"
+        file src/neard | grep "$ARCH_CHECK"
+
     - name: Install
       run: make install
 
     - name: Distribution check
       run: make distcheck
+      # distcheck runs unit tests so no point for cross compile
+      # TODO: figure out how to re-configure during distcheck with --host for i386 (DISTCHECK_CONFIGURE_FLAGS)
+      if: ${{ (matrix.env['ARCH'] == 'x86-64')}}
diff --git a/ci/alpine.sh b/ci/alpine.sh
new file mode 100755
index 000000000000..006dca22aaf9
--- /dev/null
+++ b/ci/alpine.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2019-2021 Petr Vorel <petr.vorel@gmail.com>
+# Copyright (c) 2021 Canonical Ltd.
+# Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
+#                             <krzk@kernel.org>
+#
+
+set -ex
+
+apk update
+
+PKGS_CC="gcc"
+
+# gzip: for distcheck
+apk add \
+	autoconf \
+	automake \
+	gcc \
+	gzip \
+	dbus-dev \
+	glib-dev \
+	libnl3-dev \
+	libtool \
+	make \
+	musl-dev \
+	$PKGS_CC
+
+# Packages needed by CI
+apk add \
+	file
+
+echo "Install finished: $0"
diff --git a/ci/debian.cross-compile.sh b/ci/debian.cross-compile.sh
new file mode 100755
index 000000000000..13d0c5eb1cbd
--- /dev/null
+++ b/ci/debian.cross-compile.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2018-2020 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2021 Canonical Ltd.
+# Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
+#                             <krzk@kernel.org>
+#
+
+set -ex
+
+if [ -z "$ARCH" ]; then
+	echo "missing \$ARCH!" >&2
+	exit 1
+fi
+
+case "$ARCH" in
+	armel) PKGS_CC="gcc-arm-linux-gnueabi libc6-dev-${ARCH}-cross";;
+	arm64) PKGS_CC="gcc-aarch64-linux-gnu libc6-dev-${ARCH}-cross";;
+	ppc64el) PKGS_CC="gcc-powerpc64le-linux-gnu libc6-dev-${ARCH}-cross";;
+	# TODO: libraries for riscv?
+	#riscv64) PKGS_CC="gcc-riscv64-linux-gnu libc6-dev-${ARCH}-cross";;
+	s390x) PKGS_CC="gcc-${ARCH}-linux-gnu libc6-dev-${ARCH}-cross";;
+	*) echo "unsupported arch: '$ARCH'!" >&2; exit 1;;
+esac
+
+dpkg --add-architecture $ARCH
+apt update
+
+apt install -y --no-install-recommends \
+	autoconf:${ARCH} \
+	automake:${ARCH} \
+	libdbus-1-dev:${ARCH} \
+	libglib2.0-dev:${ARCH} \
+	libnl-3-dev:${ARCH} \
+	libnl-genl-3-dev:${ARCH} \
+	libtool:${ARCH} \
+	$PKGS_CC
+
+echo "Install finished: $0"
diff --git a/ci/debian.i386.sh b/ci/debian.i386.sh
new file mode 100755
index 000000000000..db00cab37ad5
--- /dev/null
+++ b/ci/debian.i386.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2018-2020 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2021 Canonical Ltd.
+# Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
+#                             <krzk@kernel.org>
+#
+
+set -ex
+
+dpkg --add-architecture i386
+apt update
+
+# gcc-multilib are also needed for clang 32-bit builds
+PKGS_CC="gcc-multilib"
+
+apt install -y --no-install-recommends \
+	linux-libc-dev:i386
+
+apt install -y --no-install-recommends \
+	autoconf:i386 \
+	automake:i386 \
+	libdbus-1-dev:i386 \
+	libglib2.0-dev:i386 \
+	libnl-3-dev:i386 \
+	libnl-genl-3-dev:i386 \
+	libtool:i386 \
+	$PKGS_CC
+
+echo "Install finished: $0"
diff --git a/ci/debian.sh b/ci/debian.sh
index 6f407a8f26fc..dc2beecd8849 100755
--- a/ci/debian.sh
+++ b/ci/debian.sh
@@ -6,7 +6,7 @@
 #                             <krzk@kernel.org>
 #
 
-set -eEx
+set -ex
 
 apt update
 
@@ -20,10 +20,11 @@ tzdata tzdata/Zones/Europe select Berlin
 debconf-set-selections /tmp/tzdata-preseed.txt
 
 PKGS_CC="build-essential"
-if [ "$CC" = "clang" ]; then
-	PKGS_CC="clang"
-fi
-
+case $CC in
+	clang*)
+		PKGS_CC="clang"
+	;;
+esac
 
 apt install -y --no-install-recommends \
 	autoconf \
@@ -35,3 +36,5 @@ apt install -y --no-install-recommends \
 	libtool \
 	make \
 	$PKGS_CC
+
+echo "Install finished: $0"
diff --git a/ci/fedora.sh b/ci/fedora.sh
new file mode 100755
index 000000000000..ea6e8a5f5b16
--- /dev/null
+++ b/ci/fedora.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2021 Canonical Ltd.
+# Author: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
+#                             <krzk@kernel.org>
+#
+
+set -ex
+
+PKGS_CC="gcc"
+case $CC in
+	clang*)
+		PKGS_CC="clang"
+	;;
+esac
+
+yum -y install \
+	autoconf \
+	automake \
+	dbus-devel \
+	glib2-devel \
+	libnl3-devel \
+	libtool \
+	make \
+	$PKGS_CC
+
+# Packages needed by CI
+yum -y install \
+	file
+
+echo "Install finished: $0"
diff --git a/ci/ubuntu.cross-compile.sh b/ci/ubuntu.cross-compile.sh
new file mode 120000
index 000000000000..18f77ad009bb
--- /dev/null
+++ b/ci/ubuntu.cross-compile.sh
@@ -0,0 +1 @@
+debian.cross-compile.sh
\ No newline at end of file
diff --git a/ci/ubuntu.i386.sh b/ci/ubuntu.i386.sh
new file mode 120000
index 000000000000..813bdf90e6ec
--- /dev/null
+++ b/ci/ubuntu.i386.sh
@@ -0,0 +1 @@
+debian.i386.sh
\ No newline at end of file
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 05/34] ci: run unit tests
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (3 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 04/34] ci: add more build configurations (Fedora, Alpine, Debian, cross-compile, i386) Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 06/34] adapter: adjust indentation of continued arguments Krzysztof Kozlowski
                   ` (28 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Although unit tests are executed as part of distcheck, but add it as a
dedicated step to make it explicit with getting the logs afterwards.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 .github/workflows/ci.yml | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8160aada2042..7daccd2672fd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -245,6 +245,23 @@ jobs:
     - name: Compile
       run: make -j$(nproc)
 
+    - name: Run unit tests
+      id: unit_tests
+      run: |
+        make check
+      if: ${{ (matrix.env['ARCH'] == 'x86-64') || (matrix.env['ARCH'] == 'i386') }}
+
+    - name: Get unit tests logs
+      run: |
+        for i in unit/*log
+        do
+          echo "#######################"
+          echo "LOG: $i"
+          cat $i
+        done
+      if: ${{ always() && ((steps.unit_tests.outcome == 'failure') ||
+                           (steps.unit_tests.outcome == 'success')) }}
+
     - name: Check final binary
       run: |
         file src/neard
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 06/34] adapter: adjust indentation of continued arguments
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (4 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 05/34] ci: run unit tests Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 07/34] ci: display printenv Krzysztof Kozlowski
                   ` (27 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

No functional change.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/adapter.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 9c483ca28855..5a8f083a686c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -232,7 +232,7 @@ static gboolean property_get_powered(const GDBusPropertyTable *property,
 }
 
 static void set_powered(GDBusPendingPropertySet id, dbus_bool_t powered,
-								void *data)
+			void *data)
 {
 	struct near_adapter *adapter = data;
 	int err;
@@ -284,7 +284,7 @@ static void property_set_powered(const GDBusPropertyTable *property,
 }
 
 static void append_protocols(DBusMessageIter *iter,
-					struct near_adapter *adapter)
+			     struct near_adapter *adapter)
 {
 	const char *str;
 
@@ -405,7 +405,7 @@ static DBusMessage *stop_poll_loop(DBusConnection *conn,
 }
 
 static void tag_present_cb(uint32_t adapter_idx, uint32_t target_idx,
-								int status);
+			   int status);
 
 static gboolean check_presence(gpointer user_data)
 {
@@ -453,7 +453,7 @@ static gboolean dep_timer(gpointer user_data)
 }
 
 static void tag_present_cb(uint32_t adapter_idx, uint32_t target_idx,
-								int status)
+			   int status)
 {
 	struct near_adapter *adapter;
 
@@ -704,7 +704,7 @@ static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
 }
 
 static void device_read_cb(uint32_t adapter_idx, uint32_t target_idx,
-								int status)
+			   int status)
 {
 	struct near_adapter *adapter;
 
@@ -996,7 +996,7 @@ static gboolean execute_recv_cb(gpointer user_data)
 }
 
 static gboolean adapter_recv_event(GIOChannel *channel, GIOCondition condition,
-							gpointer user_data)
+				   gpointer user_data)
 {
 	struct near_adapter *adapter = user_data;
 	struct near_adapter_ioreq *req;
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 07/34] ci: display printenv
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (5 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 06/34] adapter: adjust indentation of continued arguments Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 08/34] HACKING: refine required packages Krzysztof Kozlowski
                   ` (26 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 .github/workflows/ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7daccd2672fd..a9335e100fb4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -224,6 +224,7 @@ jobs:
         lsb_release -a || true
         uname -a
         cat /proc/cmdline
+        printenv
 
     - name: Configure
       run: |
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 08/34] HACKING: refine required packages
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (6 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 07/34] ci: display printenv Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 09/34] nciattach: fix poll.h include location Krzysztof Kozlowski
                   ` (25 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Debian since Jessie (8.0 from 2015) seems to have automake v1.14, so
mentioning some specific configuration for it is not needed.  In the
same time other required libraries and tools are not mentioned, so let's
refresh the requirements list.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 HACKING | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/HACKING b/HACKING
index 478653c8a292..c1eb6d6189a6 100644
--- a/HACKING
+++ b/HACKING
@@ -5,17 +5,18 @@ Hacking on Near Field Communication manager
 Build tools requirements
 ========================
 
-When building and testing directly from the repository it is important to
-have at least automake version 1.10 or later installed. All modern
-distributions should default to the latest version, but it seems that
-Debian's default is still an earlier version:
-
-  Check version
-    # dpkg -l '*automake*'
-
-  Install new version
-    # apt-get install automake1.10
-    # update-alternatives --config automake
+Required packages and tools:
+  autoconf
+  automake
+  dbus
+  gcc/clang
+  glib 2.0
+  libtool
+  libnl-3
+  libnl-genl-3
+  make
+
+See also installation scripts for  Continuous Integration in ci/ directory.
 
 
 Working with the source code repository
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 09/34] nciattach: fix poll.h include location
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (7 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 08/34] HACKING: refine required packages Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 10/34] unit: use proper pointer to uint8_t in test_snep_read_recv_fragments() Krzysztof Kozlowski
                   ` (24 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

poll.h header should not be included from include/sys.  This works fine
on Glibc but fails on musl:

    In file included from tools/nciattach.c:42:
    /usr/include/sys/poll.h:1:2: error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Werror=cpp]
        1 | #warning redirecting incorrect #include <sys/poll.h> to <poll.h>

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 tools/nciattach.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/nciattach.c b/tools/nciattach.c
index 370f98bb176c..574c0fbe784a 100644
--- a/tools/nciattach.c
+++ b/tools/nciattach.c
@@ -32,6 +32,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <poll.h>
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
@@ -39,7 +40,6 @@
 #include <termios.h>
 #include <time.h>
 #include <sys/time.h>
-#include <sys/poll.h>
 #include <sys/param.h>
 #include <sys/ioctl.h>
 #include <termios.h>
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 10/34] unit: use proper pointer to uint8_t in test_snep_read_recv_fragments()
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (8 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 09/34] nciattach: fix poll.h include location Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 11/34] build: fix setting CFLAGS on dash shell (Alpine Linux) Krzysztof Kozlowski
                   ` (23 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Raw data bytes should be passed as pointer to uint8_t and the calling
function already uses that type.  This fixes warning:

    unit/test-snep-read.c: In function ‘test_snep_read_recv_fragments’:
    unit/test-snep-read.c:408:21: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
      408 |   memcpy(data_recvd + offset, resp, nbytes);
          |                     ^

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 unit/test-snep-read.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unit/test-snep-read.c b/unit/test-snep-read.c
index 5511fecf5c17..78db58ba859f 100644
--- a/unit/test-snep-read.c
+++ b/unit/test-snep-read.c
@@ -386,7 +386,7 @@ static bool test_snep_read_send_fragment(size_t frag_len,
  * @param[out] data             Must be preallocated
  */
 static void test_snep_read_recv_fragments(uint32_t frag_len,
-				uint32_t remaining_bytes, void *data_recvd)
+				uint32_t remaining_bytes, uint8_t *data_recvd)
 {
 	struct p2p_snep_resp_frame *resp;
 	uint32_t offset = 0;
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 11/34] build: fix setting CFLAGS on dash shell (Alpine Linux)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (9 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 10/34] unit: use proper pointer to uint8_t in test_snep_read_recv_fragments() Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 12/34] build: add more compiler warnings Krzysztof Kozlowski
                   ` (22 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Syntax like "CFLAGS+=" does not work on simple shells, e.g. dash from
BusyBox.  This seems to fail to properly configure CFLAGS on Alpine
Linux:

    checking for pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    ./configure: line 3441: CFLAGS+= -Werror -Wextra: not found
    ./configure: line 3442: CFLAGS+= -Wno-unused-parameter: not found
    ./configure: line 3443: CFLAGS+= -Wno-missing-field-initializers: not found
    ./configure: line 3444: CFLAGS+= -Wdeclaration-after-statement: not found
    ./configure: line 3445: CFLAGS+= -Wmissing-declarations: not found
    ./configure: line 3446: CFLAGS+= -Wredundant-decls: not found
    ./configure: line 3447: CFLAGS+= -Wcast-align: not found
    ./configure: line 3448: CFLAGS+= -DG_DISABLE_DEPRECATED: not found
    checking for gcc... gcc

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 acinclude.m4 | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index fbc7660dfb67..027ed69977db 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -15,13 +15,14 @@ AC_DEFUN([NEARD_COMPILER_FLAGS], [
 		CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2"
 	fi
 	if (test "$USE_MAINTAINER_MODE" = "yes"); then
-		CFLAGS+=" -Werror -Wextra"
-		CFLAGS+=" -Wno-unused-parameter"
-		CFLAGS+=" -Wno-missing-field-initializers"
-		CFLAGS+=" -Wdeclaration-after-statement"
-		CFLAGS+=" -Wmissing-declarations"
-		CFLAGS+=" -Wredundant-decls"
-		CFLAGS+=" -Wcast-align"
-		CFLAGS+=" -DG_DISABLE_DEPRECATED"
+		CFLAGS="$CFLAGS -Werror -Wextra"
+		CFLAGS="$CFLAGS -Werror -Wextra"
+		CFLAGS="$CFLAGS -Wno-unused-parameter"
+		CFLAGS="$CFLAGS -Wno-missing-field-initializers"
+		CFLAGS="$CFLAGS -Wdeclaration-after-statement"
+		CFLAGS="$CFLAGS -Wmissing-declarations"
+		CFLAGS="$CFLAGS -Wredundant-decls"
+		CFLAGS="$CFLAGS -Wcast-align"
+		CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
 	fi
 ])
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 12/34] build: add more compiler warnings
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (10 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 11/34] build: fix setting CFLAGS on dash shell (Alpine Linux) Krzysztof Kozlowski
@ 2021-07-11 20:20 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 13/34] gdbus: do not shadow global 'pending' variable (-Wshadow) Krzysztof Kozlowski
                   ` (21 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:20 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Use the AX_CHECK_COMPILE_FLAG() macro from autoconf-archive to check for
support for more compiler warning flags (not enabled via -Wall and
-Wextra) and enable these which pass.

These flags are warning for:
1. Code bugs like dereferencing NULL or truncating string operations
   functions.

2. Minor code quality or portability issues like using undefined
   defines, wrong casts of functions, missing global function
   declarations, skipping variable initializations, duplicated if
   conditions or branches, usage of variable-length arrays.

3. Portability issues like implicit promoting float to double,
   allocating zero bytes or depending of size of void *.

Keep more warnings for later, because the code does not build with them.

The AX_CHECK_COMPILE_FLAG() macro tries to compile C code with given
flag, so move the code from acinclude.m4 (executed early, before AC_LANG
and others) to separate accflags.m4.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 HACKING      |  1 +
 accflags.m4  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 acinclude.m4 | 17 -----------------
 ci/alpine.sh |  1 +
 ci/debian.sh |  1 +
 ci/fedora.sh |  1 +
 configure.ac |  5 +++--
 7 files changed, 52 insertions(+), 19 deletions(-)
 create mode 100644 accflags.m4

diff --git a/HACKING b/HACKING
index c1eb6d6189a6..7326242506a6 100644
--- a/HACKING
+++ b/HACKING
@@ -7,6 +7,7 @@ Build tools requirements
 
 Required packages and tools:
   autoconf
+  autoconf-archive
   automake
   dbus
   gcc/clang
diff --git a/accflags.m4 b/accflags.m4
new file mode 100644
index 000000000000..b1bb1500324f
--- /dev/null
+++ b/accflags.m4
@@ -0,0 +1,45 @@
+AC_DEFUN([NEARD_COMPILER_FLAGS], [
+	# AX_CHECK_COMPILE_FLAG comes from autoconf-archive
+	AC_REQUIRE([AC_PROG_CC])
+	AC_REQUIRE([AX_CHECK_COMPILE_FLAG])
+
+	if (test "${CFLAGS}" = ""); then
+		CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2"
+	fi
+	if (test "$USE_MAINTAINER_MODE" = "yes"); then
+		CFLAGS="$CFLAGS -Werror -Wextra"
+		CFLAGS="$CFLAGS -Wno-unused-parameter"
+		CFLAGS="$CFLAGS -Wno-missing-field-initializers"
+		CFLAGS="$CFLAGS -Wdeclaration-after-statement"
+		CFLAGS="$CFLAGS -Wmissing-declarations"
+		CFLAGS="$CFLAGS -Wredundant-decls"
+		CFLAGS="$CFLAGS -Wcast-align"
+		CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
+
+		AX_CHECK_COMPILE_FLAG([-Wdouble-promotion], [CFLAGS="$CFLAGS -Wdouble-promotion"])
+		AX_CHECK_COMPILE_FLAG([-Wundef], [CFLAGS="$CFLAGS -Wundef"])
+		AX_CHECK_COMPILE_FLAG([-Wbad-function-cast], [CFLAGS="$CFLAGS -Wbad-function-cast"])
+		AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [CFLAGS="$CFLAGS -Wmissing-prototypes"])
+		AX_CHECK_COMPILE_FLAG([-Wjump-misses-init], [CFLAGS="$CFLAGS -Wjump-misses-init"])
+		AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"])
+
+		# GCC v6.0
+		AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"])
+		AX_CHECK_COMPILE_FLAG([-Wduplicated-cond], [CFLAGS="$CFLAGS -Wduplicated-cond"])
+		# GCC v7.0
+		AX_CHECK_COMPILE_FLAG([-Wduplicated-branches], [CFLAGS="$CFLAGS -Wduplicated-branches"])
+		AX_CHECK_COMPILE_FLAG([-Wvla-larger-than=1], [CFLAGS="$CFLAGS -Wvla-larger-than=1"])
+		AX_CHECK_COMPILE_FLAG([-Walloc-zero], [CFLAGS="$CFLAGS -Walloc-zero"])
+		# GCC v8.0
+		AX_CHECK_COMPILE_FLAG([-Wstringop-truncation], [CFLAGS="$CFLAGS -Wstringop-truncation"])
+	fi
+	if (test "$USE_MAINTAINER_MODE" = "pedantic"); then
+		AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=3], [CFLAGS="$CFLAGS -Wstrict-overflow=3"])
+		AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"])
+		AX_CHECK_COMPILE_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"])
+		AX_CHECK_COMPILE_FLAG([-Wunsafe-loop-optimizations], [CFLAGS="$CFLAGS -Wunsafe-loop-optimizations"])
+
+		# GCC v5.0
+		AX_CHECK_COMPILE_FLAG([-Wformat-signedness], [CFLAGS="$CFLAGS -Wformat-signedness"])
+	fi
+])
diff --git a/acinclude.m4 b/acinclude.m4
index 027ed69977db..a12b93972cfa 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -9,20 +9,3 @@ AC_DEFUN([NEARD_PROG_CC_PIE], [
 		rm -rf conftest*
 	])
 ])
-
-AC_DEFUN([NEARD_COMPILER_FLAGS], [
-	if (test "${CFLAGS}" = ""); then
-		CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2"
-	fi
-	if (test "$USE_MAINTAINER_MODE" = "yes"); then
-		CFLAGS="$CFLAGS -Werror -Wextra"
-		CFLAGS="$CFLAGS -Werror -Wextra"
-		CFLAGS="$CFLAGS -Wno-unused-parameter"
-		CFLAGS="$CFLAGS -Wno-missing-field-initializers"
-		CFLAGS="$CFLAGS -Wdeclaration-after-statement"
-		CFLAGS="$CFLAGS -Wmissing-declarations"
-		CFLAGS="$CFLAGS -Wredundant-decls"
-		CFLAGS="$CFLAGS -Wcast-align"
-		CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
-	fi
-])
diff --git a/ci/alpine.sh b/ci/alpine.sh
index 006dca22aaf9..81b5c72a392e 100755
--- a/ci/alpine.sh
+++ b/ci/alpine.sh
@@ -16,6 +16,7 @@ PKGS_CC="gcc"
 # gzip: for distcheck
 apk add \
 	autoconf \
+	autoconf-archive \
 	automake \
 	gcc \
 	gzip \
diff --git a/ci/debian.sh b/ci/debian.sh
index dc2beecd8849..962e554304ee 100755
--- a/ci/debian.sh
+++ b/ci/debian.sh
@@ -28,6 +28,7 @@ esac
 
 apt install -y --no-install-recommends \
 	autoconf \
+	autoconf-archive \
 	automake \
 	libdbus-1-dev \
 	libglib2.0-dev \
diff --git a/ci/fedora.sh b/ci/fedora.sh
index ea6e8a5f5b16..c5a67d237e91 100755
--- a/ci/fedora.sh
+++ b/ci/fedora.sh
@@ -17,6 +17,7 @@ esac
 
 yum -y install \
 	autoconf \
+	autoconf-archive \
 	automake \
 	dbus-devel \
 	glib2-devel \
diff --git a/configure.ac b/configure.ac
index c4e8993305b1..b9419c1fad74 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,8 +22,6 @@ AC_SUBST(se_plugindir)
 
 PKG_PROG_PKG_CONFIG
 
-NEARD_COMPILER_FLAGS
-
 AC_LANG([C])
 
 AC_PROG_CC
@@ -34,6 +32,9 @@ AC_PROG_MKDIR_P
 m4_define([_LT_AC_TAGCONFIG], [])
 m4_ifdef([AC_LIBTOOL_TAGS], [AC_LIBTOOL_TAGS([])])
 
+m4_include([accflags.m4])
+NEARD_COMPILER_FLAGS
+
 LT_INIT([disable-static])
 
 AM_CONDITIONAL(READLINE, test "${enable_readline}" = "yes")
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 13/34] gdbus: do not shadow global 'pending' variable (-Wshadow)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (11 preceding siblings ...)
  2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 12/34] build: add more compiler warnings Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 14/34] nciattach: do not shadow other local 'opt' " Krzysztof Kozlowski
                   ` (20 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Fix -Wshadow warnings:

    gdbus/object.c: In function ‘g_dbus_pending_success’:
    gdbus/object.c:286:24: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow]
      286 |      GDBusPendingReply pending)
          |      ~~~~~~~~~~~~~~~~~~^~~~~~~
    gdbus/object.c:89:16: note: shadowed declaration is here
       89 | static GSList *pending = NULL;
          |                ^~~~~~~
    gdbus/object.c: In function ‘g_dbus_pending_error_valist’:
    gdbus/object.c:308:23: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow]
      308 |     GDBusPendingReply pending, const char *name,
          |     ~~~~~~~~~~~~~~~~~~^~~~~~~
    gdbus/object.c:89:16: note: shadowed declaration is here
       89 | static GSList *pending = NULL;
          |                ^~~~~~~
    gdbus/object.c: In function ‘g_dbus_pending_error’:
    gdbus/object.c:331:23: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow]
      331 |     GDBusPendingReply pending,
          |     ~~~~~~~~~~~~~~~~~~^~~~~~~
    gdbus/object.c:89:16: note: shadowed declaration is here
       89 | static GSList *pending = NULL;
          |                ^~~~~~~
    gdbus/object.c: In function ‘builtin_security_function’:
    gdbus/object.c:370:25: error: declaration of ‘pending’ shadows a global declaration [-Werror=shadow]
      370 |       GDBusPendingReply pending)
          |       ~~~~~~~~~~~~~~~~~~^~~~~~~
    gdbus/object.c:89:16: note: shadowed declaration is here
       89 | static GSList *pending = NULL;
          |                ^~~~~~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 gdbus/object.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index 96db51665301..f394334d4594 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -283,14 +283,14 @@ static GSList *pending_security = NULL;
 static const GDBusSecurityTable *security_table = NULL;
 
 void g_dbus_pending_success(DBusConnection *connection,
-					GDBusPendingReply pending)
+			    GDBusPendingReply pending_reply)
 {
 	GSList *list;
 
 	for (list = pending_security; list; list = list->next) {
 		struct security_data *secdata = list->data;
 
-		if (secdata->pending != pending)
+		if (secdata->pending != pending_reply)
 			continue;
 
 		pending_security = g_slist_remove(pending_security, secdata);
@@ -305,7 +305,7 @@ void g_dbus_pending_success(DBusConnection *connection,
 }
 
 void g_dbus_pending_error_valist(DBusConnection *connection,
-				GDBusPendingReply pending, const char *name,
+				GDBusPendingReply pending_reply, const char *name,
 					const char *format, va_list args)
 {
 	GSList *list;
@@ -313,7 +313,7 @@ void g_dbus_pending_error_valist(DBusConnection *connection,
 	for (list = pending_security; list; list = list->next) {
 		struct security_data *secdata = list->data;
 
-		if (secdata->pending != pending)
+		if (secdata->pending != pending_reply)
 			continue;
 
 		pending_security = g_slist_remove(pending_security, secdata);
@@ -328,14 +328,14 @@ void g_dbus_pending_error_valist(DBusConnection *connection,
 }
 
 void g_dbus_pending_error(DBusConnection *connection,
-				GDBusPendingReply pending,
+			  GDBusPendingReply pending_reply,
 				const char *name, const char *format, ...)
 {
 	va_list args;
 
 	va_start(args, format);
 
-	g_dbus_pending_error_valist(connection, pending, name, format, args);
+	g_dbus_pending_error_valist(connection, pending_reply, name, format, args);
 
 	va_end(args);
 }
@@ -365,19 +365,19 @@ static void builtin_security_result(dbus_bool_t authorized, void *user_data)
 }
 
 static void builtin_security_function(DBusConnection *conn,
-						const char *action,
-						gboolean interaction,
-						GDBusPendingReply pending)
+				      const char *action,
+				      gboolean interaction,
+				      GDBusPendingReply pending_reply)
 {
 	struct builtin_security_data *data;
 
 	data = g_new0(struct builtin_security_data, 1);
 	data->conn = conn;
-	data->pending = pending;
+	data->pending = pending_reply;
 
 	if (polkit_check_authorization(conn, action, interaction,
 				builtin_security_result, data, 30000) < 0)
-		g_dbus_pending_error(conn, pending, NULL, NULL);
+		g_dbus_pending_error(conn, pending_reply, NULL, NULL);
 }
 
 static gboolean check_privilege(DBusConnection *conn, DBusMessage *msg,
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 14/34] nciattach: do not shadow other local 'opt' variable (-Wshadow)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (12 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 13/34] gdbus: do not shadow global 'pending' variable (-Wshadow) Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 15/34] unit: do not shadow global 'uri' " Krzysztof Kozlowski
                   ` (19 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Fix -Wshadow warning:

    tools/nciattach.c: In function ‘main’:
    tools/nciattach.c:272:9: error: declaration of ‘opt’ shadows a previous local [-Werror=shadow]
      272 |   char *opt;
          |         ^~~
    tools/nciattach.c:236:24: note: shadowed declaration is here
      236 |  int detach, printpid, opt, i, n, ld, err;
          |                        ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 tools/nciattach.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/nciattach.c b/tools/nciattach.c
index 574c0fbe784a..4ac37d82d545 100644
--- a/tools/nciattach.c
+++ b/tools/nciattach.c
@@ -269,16 +269,16 @@ int main(int argc, char *argv[])
 	}
 
 	for (n = 0; optind < argc; n++, optind++) {
-		char *opt;
+		char *option;
 
-		opt = argv[optind];
+		option = argv[optind];
 
 		switch(n) {
 		case 0:
 			dev[0] = 0;
-			if (!strchr(opt, '/'))
+			if (!strchr(option, '/'))
 				strcpy(dev, "/dev/");
-			strcat(dev, opt);
+			strcat(dev, option);
 			break;
 
 		case 1:
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 15/34] unit: do not shadow global 'uri' variable (-Wshadow)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (13 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 14/34] nciattach: do not shadow other local 'opt' " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 16/34] nfctool: use proper format for integers (-Wformat) Krzysztof Kozlowski
                   ` (18 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Fix -Wshadow warnings like:

    unit/test-ndef-parse.c: In function ‘test_ndef_single_sp’:
    unit/test-ndef-parse.c:291:32: error: declaration of ‘uri’ shadows a global declaration [-Werror=shadow]
      291 |  struct near_ndef_uri_payload *uri;
          |                                ^~~
    unit/test-ndef-parse.c:145:16: note: shadowed declaration is here
      145 | static uint8_t uri[] = {0xd1, 0x1, 0xa, 0x55, 0x1, 0x69, 0x6e, 0x74,
          |                ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 unit/test-ndef-parse.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/unit/test-ndef-parse.c b/unit/test-ndef-parse.c
index afcede57b0d8..cdeb1a1a24df 100644
--- a/unit/test-ndef-parse.c
+++ b/unit/test-ndef-parse.c
@@ -142,7 +142,7 @@ struct near_ndef_ac_payload {
 };
 
 /* http://www.intel.com URI NDEF */
-static uint8_t uri[] = {0xd1, 0x1, 0xa, 0x55, 0x1, 0x69, 0x6e, 0x74,
+static uint8_t test_uri[] = {0xd1, 0x1, 0xa, 0x55, 0x1, 0x69, 0x6e, 0x74,
 			0x65, 0x6c, 0x2e, 0x63, 0x6f, 0x6d};
 
 /* 'hello żółw' - UTF-8 - en-US Text NDEF */
@@ -210,7 +210,7 @@ static void test_ndef_uri(void)
 	GList *records;
 	struct near_ndef_record *record;
 
-	records = near_ndef_parse_msg(uri, sizeof(uri), NULL);
+	records = near_ndef_parse_msg(test_uri, sizeof(test_uri), NULL);
 
 	g_assert(records);
 	g_assert_cmpuint(g_list_length(records), ==, 1);
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 16/34] nfctool: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (14 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 15/34] unit: do not shadow global 'uri' " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 17/34] bluetooth: " Krzysztof Kozlowski
                   ` (17 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print igned and nsigned integers.  This fixes warnings like:

    In file included from tools/nfctool/main.c:37:
    tools/nfctool/main.c: In function ‘nfctool_start_poll’:
    tools/nfctool/main.c:73:15: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘guint32’ {aka ‘unsigned int’} [-Werror=format=]
       73 |   print_error("Invalid adapter index: %d", opts.adapter_idx);
          |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~
          |                                                |
          |                                                guint32 {aka unsigned int}
    tools/nfctool/llcp-decode.c: In function ‘llcp_print_params’:
    tools/nfctool/llcp-decode.c:276:27: error: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘int’ [-Werror=format=]
      276 |    sprintf(param_str, "0x%X", param[2] & 0x03);
          |                          ~^   ~~~~~~~~~~~~~~~
          |                           |            |
          |                           unsigned int int
          |                          %X
    tools/nfctool/llcp-decode.c: In function ‘llcp_print_pdu’:
    tools/nfctool/llcp-decode.c:553:27: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘__time_t’ {aka ‘long int’} [-Werror=format=]
      553 |   sprintf(time_str,  "%c%lu.%06lus", prefix, msg_timestamp.tv_sec,
          |                         ~~^                  ~~~~~~~~~~~~~~~~~~~~
          |                           |                               |
          |                           long unsigned int               __time_t {aka long int}
          |                         %lu

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 tools/nfctool/adapter.c     |  4 ++--
 tools/nfctool/llcp-decode.c |  4 ++--
 tools/nfctool/main.c        | 20 ++++++++++----------
 tools/nfctool/sniffer.c     |  2 +-
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/tools/nfctool/adapter.c b/tools/nfctool/adapter.c
index 343c4ab7d0ff..5e076782e373 100644
--- a/tools/nfctool/adapter.c
+++ b/tools/nfctool/adapter.c
@@ -85,7 +85,7 @@ void adapter_print_info(struct nfc_adapter *adapter, gpointer user_data)
 	if (!adapter)
 		return;
 
-	printf("nfc%d:\n", adapter->idx);
+	printf("nfc%u:\n", adapter->idx);
 
 	adpater_print_targets(adapter, "          ");
 
@@ -164,7 +164,7 @@ struct nfc_adapter *adapter_get(guint32 idx)
 
 void adapter_add_target(struct nfc_adapter *adapter, guint8 type, guint32 idx)
 {
-	DBG("adapter_idx: %d, target_type: %d, target_idx: %d",
+	DBG("adapter_idx: %u, target_type: %u, target_idx: %u",
 	    adapter->idx, type, idx);
 
 	if (type == TARGET_TYPE_TAG)
diff --git a/tools/nfctool/llcp-decode.c b/tools/nfctool/llcp-decode.c
index 13e7ba759218..3aa222f0f39e 100644
--- a/tools/nfctool/llcp-decode.c
+++ b/tools/nfctool/llcp-decode.c
@@ -273,7 +273,7 @@ static void llcp_print_params(struct sniffer_packet *packet)
 			break;
 
 		case LLCP_PARAM_OPT:
-			sprintf(param_str, "0x%X", param[2] & 0x03);
+			sprintf(param_str, "0x%X", (unsigned int)param[2] & 0x03);
 			break;
 
 		case LLCP_PARAM_SDREQ:
@@ -550,7 +550,7 @@ int llcp_print_pdu(guint8 *data, guint32 data_len, struct timeval *timestamp)
 			prefix = '+';
 		}
 
-		sprintf(time_str,  "%c%lu.%06lus", prefix, msg_timestamp.tv_sec,
+		sprintf(time_str,  "%c%ld.%06lds", prefix, msg_timestamp.tv_sec,
 							msg_timestamp.tv_usec);
 	}
 
diff --git a/tools/nfctool/main.c b/tools/nfctool/main.c
index 72a39de3ccbf..65a0c15a9465 100644
--- a/tools/nfctool/main.c
+++ b/tools/nfctool/main.c
@@ -70,7 +70,7 @@ static int nfctool_start_poll(void)
 	adapter = adapter_get(opts.adapter_idx);
 
 	if (!adapter) {
-		print_error("Invalid adapter index: %d", opts.adapter_idx);
+		print_error("Invalid adapter index: %u", opts.adapter_idx);
 
 		return -ENODEV;
 	}
@@ -81,7 +81,7 @@ static int nfctool_start_poll(void)
 	err = nl_start_poll(adapter, opts.poll_mode);
 
 	if (err == 0) {
-		printf("Start polling on nfc%d as %s\n\n",
+		printf("Start polling on nfc%u as %s\n\n",
 			adapter->idx, nfctool_poll_mode_str(opts.poll_mode));
 		return 0;
 	}
@@ -90,9 +90,9 @@ static int nfctool_start_poll(void)
 		return err;
 
 	if (adapter->rf_mode == NFC_RF_NONE)
-		printf("nfc%d already in polling mode\n\n", adapter->idx);
+		printf("nfc%u already in polling mode\n\n", adapter->idx);
 	else
-		printf("nfc%d already activated\n\n", adapter->idx);
+		printf("nfc%u already activated\n\n", adapter->idx);
 
 	/* Don't fail if there is a pending SNL request */
 	if (opts.snl)
@@ -201,7 +201,7 @@ static int nfctool_dep_link_up_cb(guint8 cmd, guint32 idx, gpointer data)
 {
 	struct nfc_adapter *adapter;
 
-	printf("Link is UP for adapter nfc%d\n\n", idx);
+	printf("Link is UP for adapter nfc%u\n\n", idx);
 
 	if (idx != opts.adapter_idx)
 		return -ENODEV;
@@ -220,7 +220,7 @@ static int nfctool_dep_link_down_cb(guint8 cmd, guint32 idx, gpointer data)
 	if (idx != opts.adapter_idx)
 		return -ENODEV;
 
-	printf("Link is DOWN for adapter nfc%d\n\n", idx);
+	printf("Link is DOWN for adapter nfc%u\n\n", idx);
 
 	opts.snl = false;
 
@@ -269,7 +269,7 @@ static int nfctool_targets_found(guint32 adapter_idx)
 	int err;
 	struct nfc_adapter *adapter;
 
-	DBG("adapter_idx: %d", adapter_idx);
+	DBG("adapter_idx: %u", adapter_idx);
 
 	if (adapter_idx == INVALID_ADAPTER_IDX)
 		return -ENODEV;
@@ -285,7 +285,7 @@ static int nfctool_targets_found(guint32 adapter_idx)
 		goto exit;
 	}
 
-	printf("Targets found for nfc%d\n", adapter_idx);
+	printf("Targets found for nfc%u\n", adapter_idx);
 	adpater_print_targets(adapter, "  ");
 	printf("\n");
 
@@ -308,7 +308,7 @@ static int nfctool_poll_cb(guint8 cmd, guint32 idx, gpointer data)
 	if (idx != opts.adapter_idx)
 		return 0;
 
-	DBG("cmd: %d, idx: %d", cmd, idx);
+	DBG("cmd: %u, idx: %u", cmd, idx);
 
 	switch (cmd) {
 	case NFC_EVENT_TARGETS_FOUND:
@@ -347,7 +347,7 @@ static int nfctool_snl_cb(guint8 cmd, guint32 idx, gpointer data)
 {
 	GSList *sdres_list = (GSList *)data;
 
-	printf("nfc%d: Service Name lookup:\n", idx);
+	printf("nfc%u: Service Name lookup:\n", idx);
 
 	g_slist_foreach(sdres_list, (GFunc)nfctool_print_and_remove_snl,
 			GINT_TO_POINTER(idx));
diff --git a/tools/nfctool/sniffer.c b/tools/nfctool/sniffer.c
index 71ac612ea924..3d1d230a50c5 100644
--- a/tools/nfctool/sniffer.c
+++ b/tools/nfctool/sniffer.c
@@ -369,7 +369,7 @@ int sniffer_init(void)
 	if (err)
 		goto exit;
 
-	printf("Start sniffer on nfc%d\n\n", opts.adapter_idx);
+	printf("Start sniffer on nfc%u\n\n", opts.adapter_idx);
 
 exit:
 	if (err)
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 17/34] bluetooth: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (15 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 16/34] nfctool: use proper format for integers (-Wformat) Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 18/34] ndef: " Krzysztof Kozlowski
                   ` (16 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from src/near.h:36,
                     from src/bluetooth.c:32:
    src/bluetooth.c: In function ‘bt_adapter_property_changed’:
    ./include/near/log.h:45:14: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘int’ [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/bluetooth.c:465:3: note: in expansion of macro ‘DBG’
      465 |   DBG("%s: %x", property, bt_def_oob_data.class_of_device);
          |   ^~~

    In file included from src/near.h:36,
                     from src/bluetooth.c:32:
    src/bluetooth.c: In function ‘bt_adapter_property_changed’:
    ./include/near/log.h:45:14: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 5 has type ‘int’ [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/bluetooth.c:475:3: note: in expansion of macro ‘DBG’
      475 |   DBG("%s: %u", property, bt_def_oob_data.powered);
          |   ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/bluetooth.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/bluetooth.c b/src/bluetooth.c
index 3e67f1c88b84..79cfbb38e334 100644
--- a/src/bluetooth.c
+++ b/src/bluetooth.c
@@ -462,7 +462,7 @@ static gboolean bt_adapter_property_changed(DBusConnection *conn,
 		dbus_message_iter_get_basic(&var, &class);
 		bt_def_oob_data.class_of_device = class;
 
-		DBG("%s: %x", property, bt_def_oob_data.class_of_device);
+		DBG("%s: %x", property, (unsigned int)bt_def_oob_data.class_of_device);
 	} else if (g_str_equal(property, "Powered")) {
 		dbus_bool_t powered;
 
@@ -472,7 +472,7 @@ static gboolean bt_adapter_property_changed(DBusConnection *conn,
 		dbus_message_iter_get_basic(&var, &powered);
 		bt_def_oob_data.powered = powered;
 
-		DBG("%s: %u", property, bt_def_oob_data.powered);
+		DBG("%s: %d", property, bt_def_oob_data.powered);
 	}
 
 	return TRUE;
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 18/34] ndef: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (16 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 17/34] bluetooth: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 19/34] nfctype2: " Krzysztof Kozlowski
                   ` (15 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/ndef.c:1084:2: note: in expansion of macro ‘DBG’
     1084 |  DBG("payload length %d", rec_header->payload_len);
          |  ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/ndef.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ndef.c b/src/ndef.c
index 54e2e1ae170e..0d84ff4dc17b 100644
--- a/src/ndef.c
+++ b/src/ndef.c
@@ -585,7 +585,7 @@ static gboolean property_get_size(const GDBusPropertyTable *property,
 {
 	struct near_ndef_record *record = user_data;
 
-	DBG("%d", record->sp->size);
+	DBG("%u", record->sp->size);
 
 	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &record->sp->size);
 
@@ -1042,7 +1042,7 @@ static struct near_ndef_record_header *parse_record_header(uint8_t *rec,
 	uint8_t *type = NULL;
 	uint32_t header_len = 0;
 
-	DBG("length %d", length);
+	DBG("length %u", length);
 
 	if (!rec || offset >= length)
 		return NULL;
@@ -1081,7 +1081,7 @@ static struct near_ndef_record_header *parse_record_header(uint8_t *rec,
 			goto fail;
 	}
 
-	DBG("payload length %d", rec_header->payload_len);
+	DBG("payload length %u", rec_header->payload_len);
 
 	if (rec_header->il == 1) {
 		rec_header->il_length = rec[offset++];
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 19/34] nfctype2: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (17 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 18/34] ndef: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 20/34] nfctype3: " Krzysztof Kozlowski
                   ` (14 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from plugins/nfctype2.c:36:
    plugins/nfctype2.c: In function ‘data_recv’:
    ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    plugins/nfctype2.c:195:2: note: in expansion of macro ‘DBG’
      195 |  DBG("adapter %d", adapter_idx);
          |  ^~~

    plugins/nfctype2.c: In function ‘nfctype2_write’:
    plugins/nfctype2.c:458:43: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
      458 |     near_error("Not enough space on tag %zd %zd",
          |                                         ~~^
          |                                           |
          |                                           long int
          |                                         %ld
      459 |       ndef->length,
          |       ~~~~~~~~~~~~
          |           |
          |           size_t {aka long unsigned int}

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 plugins/nfctype2.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/plugins/nfctype2.c b/plugins/nfctype2.c
index dec9615b69af..3618ca177363 100644
--- a/plugins/nfctype2.c
+++ b/plugins/nfctype2.c
@@ -192,7 +192,7 @@ static int data_recv(uint8_t *resp, int length, void *data)
 	cmd.cmd = CMD_READ;
 	cmd.block = DATA_BLOCK_START + tag->current_block;
 
-	DBG("adapter %d", adapter_idx);
+	DBG("adapter %u", adapter_idx);
 
 	return near_adapter_send(adapter_idx,
 				(uint8_t *) &cmd, CMD_READ_SIZE,
@@ -341,7 +341,7 @@ static int nfctype2_read(uint32_t adapter_idx,
 			cb, tgt_subtype);
 
 	default:
-		DBG("Unknown Tag Type 2 subtype %d", tgt_subtype);
+		DBG("Unknown Tag Type 2 subtype %u", tgt_subtype);
 		return -1;
 	}
 }
@@ -455,7 +455,7 @@ static int nfctype2_write(uint32_t adapter_idx, uint32_t target_idx,
 		 */
 		if (near_tag_get_memory_layout(tag) == NEAR_TAG_MEMORY_STATIC) {
 			if ((ndef->length + 3) > near_tag_get_data_length(tag)) {
-				near_error("Not enough space on tag %zd %zd",
+				near_error("Not enough space on tag %zu %zu",
 						ndef->length,
 						near_tag_get_data_length(tag));
 				err = -ENOSPC;
@@ -471,7 +471,7 @@ static int nfctype2_write(uint32_t adapter_idx, uint32_t target_idx,
 		return mifare_write(adapter_idx, target_idx, ndef,
 				cb, tgt_subtype);
 	default:
-		DBG("Unknown TAG Type 2 subtype %d", tgt_subtype);
+		DBG("Unknown TAG Type 2 subtype %u", tgt_subtype);
 		err = -EINVAL;
 		goto out_err;
 	}
@@ -533,7 +533,7 @@ static int nfctype2_check_presence(uint32_t adapter_idx, uint32_t target_idx,
 							cb, tgt_subtype);
 
 	default:
-		DBG("Unknown TAG Type 2 subtype %d", tgt_subtype);
+		DBG("Unknown TAG Type 2 subtype %u", tgt_subtype);
 
 		return -1;
 	}
@@ -586,7 +586,7 @@ static int nfctype2_format(uint32_t adapter_idx, uint32_t target_idx,
 	tgt_subtype = near_tag_get_subtype(adapter_idx, target_idx);
 
 	if (tgt_subtype != NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT) {
-		DBG("Unknown Tag Type 2 subtype %d", tgt_subtype);
+		DBG("Unknown Tag Type 2 subtype %u", tgt_subtype);
 		return -1;
 	}
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 20/34] nfctype3: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (18 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 19/34] nfctype2: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 21/34] nfctype5: " Krzysztof Kozlowski
                   ` (13 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from plugins/nfctype3.c:36:
    plugins/nfctype3.c: In function ‘data_recv’:
    ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    plugins/nfctype3.c:249:3: note: in expansion of macro ‘DBG’
      249 |   DBG("Done reading %zd bytes at %p", data_length, nfc_data);
          |   ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 plugins/nfctype3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/nfctype3.c b/plugins/nfctype3.c
index d4fbed0dfc2f..c0502f15d9f2 100644
--- a/plugins/nfctype3.c
+++ b/plugins/nfctype3.c
@@ -246,7 +246,7 @@ static int data_recv(uint8_t *resp, int length, void *data)
 
 		tag->current_block = 0;
 
-		DBG("Done reading %zd bytes at %p", data_length, nfc_data);
+		DBG("Done reading %zu bytes at %p", data_length, nfc_data);
 		records = near_ndef_parse_msg(nfc_data, data_length, NULL);
 		near_tag_add_records(tag->tag, records, tag->cb, 0);
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 21/34] nfctype5: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (19 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 20/34] nfctype3: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 22/34] mifare: " Krzysztof Kozlowski
                   ` (12 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from plugins/nfctype5.c:29:
    plugins/nfctype5.c: In function ‘t5_read’:
    ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    plugins/nfctype5.c:437:2: note: in expansion of macro ‘DBG’
      437 |  DBG("Reading %zd bytes starting at offset %d\n", len, offset);
          |  ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 plugins/nfctype5.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/nfctype5.c b/plugins/nfctype5.c
index b7d240e519be..eef2afe9f6d0 100644
--- a/plugins/nfctype5.c
+++ b/plugins/nfctype5.c
@@ -434,7 +434,7 @@ static int t5_read(struct near_tag *tag, uint8_t offset, uint8_t *buf,
 	uint8_t blk_size = near_tag_get_blk_size(tag);
 	int err;
 
-	DBG("Reading %zd bytes starting at offset %d\n", len, offset);
+	DBG("Reading %zu bytes starting at offset %u\n", len, offset);
 
 	err = t5_cmd_hdr_init(tag, &t5_cmd.hdr, CMD_READ_SINGLE_BLOCK);
 	if (err)
@@ -532,10 +532,10 @@ static int t5_write(struct near_tag *tag, uint8_t offset, uint8_t *buf,
 	uint8_t blk_size = near_tag_get_blk_size(tag);
 	int err;
 
-	DBG("Writing %zd bytes starting at offset %d\n", len, offset);
+	DBG("Writing %zu bytes starting at offset %u\n", len, offset);
 
 	if (offset % blk_size) {
-		near_error("Write - Invalid offset - offset: %d, blk_size: %d",
+		near_error("Write - Invalid offset - offset: %u, blk_size: %u",
 			   offset, blk_size);
 		return -EINVAL;
 	}
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 22/34] mifare: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (20 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 21/34] nfctype5: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 23/34] p2p: " Krzysztof Kozlowski
                   ` (11 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    plugins/mifare.c: In function ‘mifare_read’:
    plugins/mifare.c:836:33: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘unsigned int’ [-Werror=format=]
      836 |   near_error("Mifare tag type [%d] not supported.", tgt_subtype);
          |                                ~^                   ~~~~~~~~~~~
          |                                 |                   |
          |                                 int                 unsigned int
          |                                %d

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 plugins/mifare.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/plugins/mifare.c b/plugins/mifare.c
index 3d376526735d..a4e4ba443995 100644
--- a/plugins/mifare.c
+++ b/plugins/mifare.c
@@ -833,7 +833,7 @@ int mifare_read(uint32_t adapter_idx, uint32_t target_idx,
 	case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K:
 		break;
 	default:
-		near_error("Mifare tag type [%d] not supported.", tgt_subtype);
+		near_error("Mifare tag type [%u] not supported.", tgt_subtype);
 		return -1;
 	}
 
@@ -900,7 +900,7 @@ int mifare_check_presence(uint32_t adapter_idx, uint32_t target_idx,
 	case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K:
 		break;
 	default:
-		near_error("Mifare tag type %d not supported.", tgt_subtype);
+		near_error("Mifare tag type %u not supported.", tgt_subtype);
 		return -1;
 	}
 
@@ -1228,7 +1228,7 @@ static int writing_not_permitted(void *data)
 		}
 	}
 
-	DBG("TAG writable sectors' size: [%d].", new_tag_size);
+	DBG("TAG writable sectors' size: [%u].", new_tag_size);
 
 	/* Check if there's enough space on tag */
 	if (new_tag_size < mf_ck->ndef->length) {
@@ -1293,7 +1293,7 @@ int mifare_write(uint32_t adapter_idx, uint32_t target_idx,
 	case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K:
 		break;
 	default:
-		near_error("Mifare tag type %d not supported.", tgt_subtype);
+		near_error("Mifare tag type %u not supported.", tgt_subtype);
 		return -1;
 	}
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 23/34] p2p: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (21 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 22/34] mifare: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 24/34] npp: " Krzysztof Kozlowski
                   ` (10 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from plugins/p2p.c:38:
    plugins/p2p.c: In function ‘p2p_listener_event’:
    ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘__u32’ {aka ‘unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    plugins/p2p.c:261:2: note: in expansion of macro ‘DBG’
      261 |  DBG("target idx %d", client_addr.target_idx);
          |  ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 plugins/p2p.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/plugins/p2p.c b/plugins/p2p.c
index 13702ade3e14..cf3e0accaf33 100644
--- a/plugins/p2p.c
+++ b/plugins/p2p.c
@@ -256,9 +256,9 @@ static gboolean p2p_listener_event(GIOChannel *channel, GIOCondition condition,
 		return FALSE;
 	}
 
-	DBG("client dsap %d ssap %d",
+	DBG("client dsap %u ssap %u",
 		client_addr.dsap, client_addr.ssap);
-	DBG("target idx %d", client_addr.target_idx);
+	DBG("target idx %u", client_addr.target_idx);
 
 	client_data = g_try_malloc0(sizeof(struct p2p_data));
 	if (!client_data) {
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 24/34] npp: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (22 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 23/34] p2p: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 25/34] adapter: " Krzysztof Kozlowski
                   ` (9 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from plugins/npp.c:36:
    plugins/npp.c: In function ‘npp_push’:
    ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    plugins/npp.c:185:2: note: in expansion of macro ‘DBG’
      185 |  DBG("Sending %zd bytes", frame_length);
          |  ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 plugins/npp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/npp.c b/plugins/npp.c
index 6bed302b4a8f..5c9d2e0cd003 100644
--- a/plugins/npp.c
+++ b/plugins/npp.c
@@ -182,7 +182,7 @@ static int npp_push(int fd, uint32_t adapter_idx, uint32_t target_idx,
 	entry->ndef_length = GINT_TO_BE(ndef->length);
 	memcpy(entry->ndef, ndef->data, ndef->length);
 
-	DBG("Sending %zd bytes", frame_length);
+	DBG("Sending %zu bytes", frame_length);
 
 	err = send(fd, frame, frame_length, MSG_DONTWAIT);
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 25/34] adapter: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (23 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 24/34] npp: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 26/34] device: " Krzysztof Kozlowski
                   ` (8 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    src/adapter.c: In function ‘near_adapter_disconnect’:
    ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/adapter.c:1095:2: note: in expansion of macro ‘DBG’
     1095 |  DBG("idx %d", idx);
          |  ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/adapter.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 5a8f083a686c..420127f4f396 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -566,7 +566,7 @@ struct near_adapter *__near_adapter_create(uint32_t idx,
 							NULL, free_device);
 	adapter->device_sock = -1;
 
-	adapter->path = g_strdup_printf("%s/nfc%d", NFC_PATH, idx);
+	adapter->path = g_strdup_printf("%s/nfc%u", NFC_PATH, idx);
 
 	return adapter;
 }
@@ -597,7 +597,7 @@ int __near_adapter_set_dep_state(uint32_t idx, bool dep)
 {
 	struct near_adapter *adapter;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -639,7 +639,7 @@ bool __near_adapter_get_dep_state(uint32_t idx)
 {
 	struct near_adapter *adapter;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -821,7 +821,7 @@ int __near_adapter_add_target(uint32_t idx, uint32_t target_idx,
 	struct near_adapter *adapter;
 	int ret;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -852,7 +852,7 @@ int __near_adapter_remove_target(uint32_t idx, uint32_t target_idx)
 {
 	struct near_adapter *adapter;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -875,11 +875,11 @@ static gboolean poll_error(gpointer user_data)
 	struct near_adapter *adapter = user_data;
 	bool reset;
 
-	DBG("adapter %d", adapter->idx);
+	DBG("adapter %u", adapter->idx);
 
 	reset = near_setting_get_bool("ResetOnError");
 	if (reset) {
-		near_error("Resetting nfc%d", adapter->idx);
+		near_error("Resetting nfc%u", adapter->idx);
 		 __near_netlink_adapter_enable(adapter->idx, false);
 		 __near_netlink_adapter_enable(adapter->idx, true);
 	}
@@ -893,7 +893,7 @@ int __near_adapter_get_targets_done(uint32_t idx)
 {
 	struct near_adapter *adapter;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -920,7 +920,7 @@ int __near_adapter_add_device(uint32_t idx, uint8_t *nfcid, uint8_t nfcid_len)
 	struct near_adapter *adapter;
 	int ret;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -944,7 +944,7 @@ int __near_adapter_remove_device(uint32_t idx)
 	struct near_adapter *adapter;
 	uint32_t device_idx = 0;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -1040,7 +1040,7 @@ int near_adapter_connect(uint32_t idx, uint32_t target_idx, uint8_t protocol)
 	struct sockaddr_nfc addr;
 	int err, sock;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -1092,7 +1092,7 @@ int near_adapter_disconnect(uint32_t idx)
 	uint32_t target_idx;
 	uint16_t tag_type;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter)
@@ -1106,7 +1106,7 @@ int near_adapter_disconnect(uint32_t idx)
 	tag_type = __near_tag_get_type(adapter->tag_link);
 	target_idx = near_tag_get_target_idx(adapter->tag_link);
 
-	DBG("tag type %d", tag_type);
+	DBG("tag type %u", tag_type);
 
 	__near_adapter_remove_target(adapter->idx, target_idx);
 
@@ -1133,7 +1133,7 @@ int near_adapter_send(uint32_t idx, uint8_t *buf, size_t length,
 	struct near_adapter_ioreq *req = NULL;
 	int err;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
 	if (!adapter) {
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 26/34] device: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (24 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 25/34] adapter: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 27/34] manager: " Krzysztof Kozlowski
                   ` (7 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    src/device.c: In function ‘near_device_get_device’:
    src/device.c:85:33: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       85 |  path = g_strdup_printf("%s/nfc%d/device%d", NFC_PATH,
          |                                ~^
          |                                 |
          |                                 int
          |                                %d
       86 |      adapter_idx, target_idx);
          |      ~~~~~~~~~~~
          |      |
          |      uint32_t {aka unsigned int}

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/device.c b/src/device.c
index a6598e0ddd28..aeae7d39a290 100644
--- a/src/device.c
+++ b/src/device.c
@@ -82,7 +82,7 @@ struct near_device *near_device_get_device(uint32_t adapter_idx,
 
 	DBG("");
 
-	path = g_strdup_printf("%s/nfc%d/device%d", NFC_PATH,
+	path = g_strdup_printf("%s/nfc%u/device%u", NFC_PATH,
 					adapter_idx, target_idx);
 	if (!path)
 		return NULL;
@@ -305,7 +305,7 @@ int near_device_add_records(struct near_device *device, GList *records,
 	for (list = records; list; list = list->next) {
 		record = list->data;
 
-		path = g_strdup_printf("%s/nfc%d/device%d/record%d",
+		path = g_strdup_printf("%s/nfc%u/device%u/record%u",
 					NFC_PATH, device->adapter_idx,
 					device->target_idx, device->n_records);
 
@@ -342,7 +342,7 @@ struct near_device *__near_device_add(uint32_t adapter_idx, uint32_t target_idx,
 	if (!device)
 		return NULL;
 
-	device->path = g_strdup_printf("%s/nfc%d/device%d", NFC_PATH,
+	device->path = g_strdup_printf("%s/nfc%u/device%u", NFC_PATH,
 					adapter_idx, target_idx);
 	if (!device->path) {
 		g_free(device);
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 27/34] manager: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (25 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 26/34] device: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 28/34] tag: " Krzysztof Kozlowski
                   ` (6 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from src/near.h:36,
                     from src/manager.c:34:
    src/manager.c: In function ‘__near_manager_adapter_add’:
    ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/manager.c:45:2: note: in expansion of macro ‘DBG’
       45 |  DBG("idx %d", idx);
          |  ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index e4b72a73fcbb..754c254d85ad 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -42,7 +42,7 @@ int __near_manager_adapter_add(uint32_t idx, const char *name,
 	const char *path;
 	int err;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = __near_adapter_create(idx, name, protocols, powered);
 	if (!adapter)
@@ -66,7 +66,7 @@ void __near_manager_adapter_remove(uint32_t idx)
 	struct near_adapter *adapter;
 	const char *path;
 
-	DBG("idx %d", idx);
+	DBG("idx %u", idx);
 
 	adapter = __near_adapter_get(idx);
 	if (!adapter)
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 28/34] tag: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (26 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 27/34] manager: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 29/34] netlink: " Krzysztof Kozlowski
                   ` (5 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    src/tag.c: In function ‘near_tag_get_tag’:
    src/tag.c:99:33: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       99 |  path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH,
          |                                ~^
          |                                 |
          |                                 int
          |                                %d
      100 |      adapter_idx, target_idx);
          |      ~~~~~~~~~~~
          |      |
          |      uint32_t {aka unsigned int}

    In file included from src/near.h:36,
                     from src/tag.c:35:
    src/tag.c: In function ‘near_tag_set_nfcid’:
    ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/tag.c:791:2: note: in expansion of macro ‘DBG’
      791 |  DBG("NFCID len %zd", nfcid_len);
          |  ^~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/tag.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/tag.c b/src/tag.c
index 9eba4eefef35..520368b1552c 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -96,7 +96,7 @@ struct near_tag *near_tag_get_tag(uint32_t adapter_idx, uint32_t target_idx)
 	struct near_tag *tag;
 	char *path;
 
-	path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH,
+	path = g_strdup_printf("%s/nfc%u/tag%u", NFC_PATH,
 					adapter_idx, target_idx);
 	if (!path)
 		return NULL;
@@ -658,7 +658,7 @@ static int tag_initialize(struct near_tag *tag,
 {
 	DBG("");
 
-	tag->path = g_strdup_printf("%s/nfc%d/tag%d", NFC_PATH,
+	tag->path = g_strdup_printf("%s/nfc%u/tag%u", NFC_PATH,
 					adapter_idx, target_idx);
 	if (!tag->path)
 		return -ENOMEM;
@@ -788,7 +788,7 @@ int near_tag_set_nfcid(uint32_t adapter_idx, uint32_t target_idx,
 {
 	struct near_tag *tag;
 
-	DBG("NFCID len %zd", nfcid_len);
+	DBG("NFCID len %zu", nfcid_len);
 
 	tag = near_tag_get_tag(adapter_idx, target_idx);
 	if (!tag)
@@ -881,7 +881,7 @@ int near_tag_add_records(struct near_tag *tag, GList *records,
 	for (list = records; list; list = list->next) {
 		record = list->data;
 
-		path = g_strdup_printf("%s/nfc%d/tag%d/record%d",
+		path = g_strdup_printf("%s/nfc%u/tag%u/record%u",
 					NFC_PATH, tag->adapter_idx,
 					tag->target_idx, tag->next_record);
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 29/34] netlink: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (27 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 28/34] tag: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 30/34] se: " Krzysztof Kozlowski
                   ` (4 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    src/netlink.c: In function ‘nfc_netlink_event_tm_deactivated’:
    ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    src/netlink.c:759:2: note: in expansion of macro ‘DBG’
      759 |  DBG("%d", idx);
          |  ^~~
    src/netlink.c: In function ‘nfc_netlink_event’:
    src/netlink.c:772:54: error: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘__u32’ {aka ‘unsigned int’} [-Werror=format=]
      772 |   near_error("WARNING: Wrong netlink message sender %d",
          |                                                     ~^
          |                                                      |
          |                                                      int
          |                                                     %d
      773 |         src->nl_pid);
          |         ~~~~~~~~~~~
          |            |
          |            __u32 {aka unsigned int}

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/netlink.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/netlink.c b/src/netlink.c
index 3c77999a05f2..a3b206aeaa88 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -567,7 +567,7 @@ static int get_targets_handler(struct nl_msg *n, void *arg)
 		iso15693_uid_len = 0;
 	}
 
-	DBG("target idx %d proto 0x%x sens_res 0x%x sel_res 0x%x NFCID len %d",
+	DBG("target idx %u proto 0x%x sens_res 0x%x sel_res 0x%x NFCID len %d",
 	    target_idx, protocols, sens_res, sel_res, nfcid_len);
 	DBG("\tiso15693_uid_len %d", iso15693_uid_len);
 
@@ -607,7 +607,7 @@ static int nfc_netlink_event_targets_found(struct genlmsghdr *gnlh)
 
 	adapter_idx = nla_get_u32(attr[NFC_ATTR_DEVICE_INDEX]);
 
-	DBG("adapter %d", adapter_idx);
+	DBG("adapter %u", adapter_idx);
 
 	msg = nlmsg_alloc();
 	if (!msg)
@@ -653,7 +653,7 @@ static int nfc_netlink_event_target_lost(struct genlmsghdr *gnlh)
 	adapter_idx = nla_get_u32(attr[NFC_ATTR_DEVICE_INDEX]);
 	target_idx = nla_get_u32(attr[NFC_ATTR_TARGET_INDEX]);
 
-	DBG("adapter %d target %d", adapter_idx, target_idx);
+	DBG("adapter %u target %u", adapter_idx, target_idx);
 
 	return __near_adapter_remove_target(adapter_idx, target_idx);
 }
@@ -690,7 +690,7 @@ static int nfc_netlink_event_dep_up(struct genlmsghdr *gnlh)
 
 		target_idx = nla_get_u32(attrs[NFC_ATTR_TARGET_INDEX]);
 
-		DBG("%d %d", idx, target_idx);
+		DBG("%u %u", idx, target_idx);
 
 		return __near_adapter_set_dep_state(idx, true);
 	} else {
@@ -735,7 +735,7 @@ static int nfc_netlink_event_tm_activated(struct genlmsghdr *gnlh)
 
 	idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]);
 
-	DBG("%d", idx);
+	DBG("%u", idx);
 
 	return __near_adapter_add_device(idx, NULL, 0);
 }
@@ -756,7 +756,7 @@ static int nfc_netlink_event_tm_deactivated(struct genlmsghdr *gnlh)
 
 	idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]);
 
-	DBG("%d", idx);
+	DBG("%u", idx);
 
 	return __near_adapter_remove_device(idx);
 }
@@ -769,8 +769,8 @@ static int nfc_netlink_event(struct nl_msg *n, void *arg)
 	DBG("event 0x%x", gnlh->cmd);
 
 	if (src->nl_pid) {
-		near_error("WARNING: Wrong netlink message sender %d",
-								src->nl_pid);
+		near_error("WARNING: Wrong netlink message sender %u",
+			   src->nl_pid);
 		return NL_SKIP;
 	}
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 30/34] se: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (28 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 29/34] netlink: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 31/34] ndef: " Krzysztof Kozlowski
                   ` (3 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    In file included from se/plugins/nfc.c:37:
    se/plugins/nfc.c: In function ‘nfc_netlink_event_se’:
    ./include/near/log.h:45:14: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    se/plugins/nfc.c:200:2: note: in expansion of macro ‘DBG’
      200 |  DBG("NFC %d SE %d", nfc_idx, se_idx);
          |  ^~~

    se/plugins/nfc.c:270:2: note: in expansion of macro ‘DBG’
      270 |  DBG("NFC %d SE %d APDU len %zd", nfc_idx, se_idx, apdu_len);
          |  ^~~
    ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 6 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~

    In file included from se/../src/near.h:36,
                     from se/seel.h:29,
                     from se/se.c:34:
    se/se.c: In function ‘io_cb’:
    ./include/near/log.h:45:14: error: format ‘%zd’ expects argument of type ‘signed size_t’, but argument 4 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
       45 |   near_debug("%s:%s() " fmt, \
          |              ^~~~~~~~~~
    se/se.c:119:2: note: in expansion of macro ‘DBG’
      119 |  DBG("%zd %d", apdu_length, err);
          |  ^~~
    se/se.c: In function ‘se_path’:
    se/se.c:250:43: error: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
      250 |  return g_strdup_printf("%s/se/%s%d_%s_se%d", SEEL_PATH,
          |                                          ~^
          |                                           |
          |                                           int
          |                                          %d
      251 |      ctrl, ctrl_idx, type, se_idx);
          |                            ~~~~~~
          |                            |
          |                            uint32_t {aka unsigned int}

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 se/ace.c           | 34 +++++++++++++++++-----------------
 se/apdu.c          |  8 ++++----
 se/plugins/nfc.c   |  8 ++++----
 se/plugins/tizen.c |  2 +-
 se/se.c            |  6 +++---
 5 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/se/ace.c b/se/ace.c
index ef0e7e15fbf7..f8d492f423af 100644
--- a/se/ace.c
+++ b/se/ace.c
@@ -126,7 +126,7 @@ static void dump_rule(gpointer data, gpointer user_data)
 		for (i = 0; i < rule->aid_len; i++)
 			sprintf(aid + (3 * i), "%02X ", rule->aid[i]);
 		aid[3 * i] = 0;
-		DBG("  AID [%zd]: %s", rule->aid_len, aid);
+		DBG("  AID [%zu]: %s", rule->aid_len, aid);
 	}
 
 	if (rule->hash_len == 0) {
@@ -135,7 +135,7 @@ static void dump_rule(gpointer data, gpointer user_data)
 		for (i = 0; i < rule->hash_len; i++)
 			sprintf(hash + (3 * i), "%02X ", rule->hash[i]);
 		hash[3 * i] = 0;
-		DBG("  Hash [%zd]: %s", rule->hash_len, hash);
+		DBG("  Hash [%zu]: %s", rule->hash_len, hash);
 	}
 
 	if (rule->apdu_rules_len == 1) {
@@ -159,7 +159,7 @@ static void dump_rule(gpointer data, gpointer user_data)
 		n_rules = rule->apdu_rules_len /
 				sizeof(struct seel_ace_apdu_rule);
 
-		DBG("  APDU rules (%zd)", n_rules);
+		DBG("  APDU rules (%zu)", n_rules);
 		for (i = 0; i < n_rules; i++) {
 			header = (uint8_t *)&apdu_rule->header;
 			mask = (uint8_t *)&apdu_rule->mask;
@@ -197,7 +197,7 @@ static int build_ref(struct seel_ace_rule *ace_rule,
 		switch (rule_ptr[0]) {
 		case AID_REF_DO:
 			do_length = rule_ptr[1];
-			DBG("AID_REF_DO %zd", do_length);
+			DBG("AID_REF_DO %zu", do_length);
 			rule_ptr += 2;
 
 			if (remaining < do_length)
@@ -216,7 +216,7 @@ static int build_ref(struct seel_ace_rule *ace_rule,
 
 		case HASH_REF_DO:
 			do_length = rule_ptr[1];
-			DBG("HASH_REF_DO %zd", do_length);
+			DBG("HASH_REF_DO %zu", do_length);
 			rule_ptr += 2;
 
 			if (remaining < do_length)
@@ -254,7 +254,7 @@ static int build_ar(struct seel_ace_rule *ace_rule,
 		switch (rule_ptr[0]) {
 		case APDU_AR_DO:
 			do_length = rule_ptr[1];
-			DBG("APDU_AR_DO %zd", do_length);
+			DBG("APDU_AR_DO %zu", do_length);
 			rule_ptr += 2;
 
 			if (remaining < do_length)
@@ -274,7 +274,7 @@ static int build_ar(struct seel_ace_rule *ace_rule,
 
 		case NFC_AR_DO:
 			do_length = rule_ptr[1];
-			DBG("NFC_AR_DO %zd", do_length);
+			DBG("NFC_AR_DO %zu", do_length);
 			rule_ptr += 2;
 
 			if (do_length != 1)
@@ -316,7 +316,7 @@ static struct seel_ace_rule *build_rule(struct seel_ace *ace,
 		switch (rule_ptr[0]) {
 		case REF_DO:
 			do_length = rule_ptr[1];
-			DBG("REF_DO %zd", do_length);
+			DBG("REF_DO %zu", do_length);
 			rule_ptr += 2;
 
 			err = build_ref(ace_rule, rule_ptr, do_length);
@@ -330,7 +330,7 @@ static struct seel_ace_rule *build_rule(struct seel_ace *ace,
 
 		case AR_DO:
 			do_length = rule_ptr[1];
-			DBG("AR_DO %zd", do_length);
+			DBG("AR_DO %zu", do_length);
 			rule_ptr += 2;
 
 			err = build_ar(ace_rule, rule_ptr, do_length);
@@ -378,7 +378,7 @@ static int build_ace_rules(struct seel_ace *ace,
 		remaining -= ref_ar_do_length + 2;
 		rule_ptr += 2;
 
-		DBG("REF_AR_DO %zd bytes", ref_ar_do_length);
+		DBG("REF_AR_DO %zu bytes", ref_ar_do_length);
 
 		rule = build_rule(ace, rule_ptr, ref_ar_do_length);
 		if (!rule) {
@@ -412,7 +412,7 @@ static int ace_rule_length(uint8_t *apdu, size_t apdu_length,
 	if (length & 0x80) {
 		size_t _length = length & 0x7f, i, base;
 
-		DBG("%zd", _length);
+		DBG("%zu", _length);
 
 		if (apdu_length < 3 + _length)
 			return -EINVAL;
@@ -441,7 +441,7 @@ static void get_next_gp_data_cb(void *context,
 	struct seel_ace *ace  = context;
 	size_t payload_length;
 
-	DBG("Current %zd Total %zd Got %zd",
+	DBG("Current %zu Total %zu Got %zu",
 		ace->current_rules_length, ace->rules_length, apdu_length);
 
 	if (err)
@@ -523,7 +523,7 @@ static void get_all_gp_data_cb(void *context,
 	payload_length = apdu_length - GET_ALL_DATA_CMD_LEN -
 					length_length - APDU_STATUS_LEN;
 
-	DBG("Received %zd bytes of payload", payload_length);
+	DBG("Received %zu bytes of payload", payload_length);
 
 	if (payload_length < (size_t)rule_length) {
 		ace->rules_length = rule_length;
@@ -655,7 +655,7 @@ static struct seel_ace_rule *find_specific_rule(struct seel_ace *ace,
 {
 	GSList *list;
 
-	DBG("%zd", aid_len);
+	DBG("%zu", aid_len);
 
 	if (!hash || !aid)
 		return false;
@@ -684,7 +684,7 @@ static bool find_specific_rule_for_aid(struct seel_ace *ace,
 {
 	GSList *list;
 
-	DBG("%zd", aid_len);
+	DBG("%zu", aid_len);
 
 	if (!aid)
 		return false;
@@ -713,7 +713,7 @@ static struct seel_ace_rule *find_generic_rule_for_aid(struct seel_ace *ace,
 {
 	GSList *list;
 
-	DBG("%zd", aid_len);
+	DBG("%zu", aid_len);
 
 	if (!aid)
 		return false;
@@ -833,7 +833,7 @@ bool __seel_ace_apdu_allowed(struct seel_channel *channel, uint8_t *hash,
 	uint8_t *aid;
 	size_t aid_len;
 
-	DBG("%zd", apdu_len);
+	DBG("%zu", apdu_len);
 
 	/* XXX Do we need to do some filtering on the basic channel ?*/
 	if (__seel_channel_is_basic(channel))
diff --git a/se/apdu.c b/se/apdu.c
index f5ba28f8046c..fe0e6319732b 100644
--- a/se/apdu.c
+++ b/se/apdu.c
@@ -131,7 +131,7 @@ struct seel_apdu *__seel_apdu_build(uint8_t *apdu, size_t length, uint8_t channe
 	}
 
 	if (channel > 3) {
-		DBG("Invalid channel number %d", channel);
+		DBG("Invalid channel number %u", channel);
 		channel = 0;
 	}
 
@@ -159,7 +159,7 @@ void __seel_apdu_dump(uint8_t *apdu, size_t length)
 		sprintf(str + (3 * i), "%02X ", apdu[i]);
 	str[3 * length] = 0;
 
-	DBG("[%zd] %s", length, str);
+	DBG("[%zu] %s", length, str);
 
 	g_free(str);
 }
@@ -188,7 +188,7 @@ struct seel_apdu *__seel_apdu_open_logical_channel(void)
 
 struct seel_apdu *__seel_apdu_close_logical_channel(uint8_t channel)
 {
-	DBG("%d", channel);
+	DBG("%u", channel);
 
 	return alloc_apdu(CLA_CHANNEL_STANDARD, 0, INS_MANAGE_CHANNEL, 0x80,
 							channel, 0, NULL, -1);
@@ -197,7 +197,7 @@ struct seel_apdu *__seel_apdu_close_logical_channel(uint8_t channel)
 struct seel_apdu *__seel_apdu_select_aid(uint8_t channel,
 						uint8_t *aid, size_t aid_length)
 {
-	DBG("%zd", aid_length);
+	DBG("%zu", aid_length);
 
 	if (aid_length < MIN_AID_LENGTH ||
 			aid_length > MAX_AID_LENGTH)
diff --git a/se/plugins/nfc.c b/se/plugins/nfc.c
index 75aba3b072f7..e2f54126119f 100644
--- a/se/plugins/nfc.c
+++ b/se/plugins/nfc.c
@@ -197,7 +197,7 @@ static int nfc_netlink_event_se(struct genlmsghdr *gnlh, bool add)
 	nfc_idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]);
 	se_idx = nla_get_u32(attrs[NFC_ATTR_SE_INDEX]);
 
-	DBG("NFC %d SE %d", nfc_idx, se_idx);
+	DBG("NFC %u SE %u", nfc_idx, se_idx);
 
 	if (add) {
 		uint8_t se_type, seel_se_type;
@@ -209,7 +209,7 @@ static int nfc_netlink_event_se(struct genlmsghdr *gnlh, bool add)
 
 		se_type = nla_get_u8(attrs[NFC_ATTR_SE_TYPE]);
 		seel_se_type = nfc_se_type(se_type);
-		DBG("NFC SE type %d %d", se_type, seel_se_type);
+		DBG("NFC SE type %u %u", se_type, seel_se_type);
 
 		return seel_manager_se_add(se_idx, nfc_idx, seel_se_type,
 						SEEL_CONTROLLER_NFC);
@@ -267,7 +267,7 @@ static int nfc_netlink_event_io(struct genlmsghdr *gnlh)
 		goto out;
 	}
 
-	DBG("NFC %d SE %d APDU len %zd", nfc_idx, se_idx, apdu_len);
+	DBG("NFC %u SE %u APDU len %zu", nfc_idx, se_idx, apdu_len);
 
 	nfc_state->ctx->cb(nfc_state->ctx->context, apdu, apdu_len, 0);
 
@@ -550,7 +550,7 @@ static int nfc_transceive(uint8_t ctrl_idx, uint32_t se_idx,
 	void *hdr;
 	int err;
 
-	DBG("%zd APDU %p", apdu_length, apdu);
+	DBG("%zu APDU %p", apdu_length, apdu);
 
 	if (nfc_state->ctx)
 		return -EALREADY;
diff --git a/se/plugins/tizen.c b/se/plugins/tizen.c
index 6bdbc2473cee..e2ea4dec4212 100644
--- a/se/plugins/tizen.c
+++ b/se/plugins/tizen.c
@@ -375,7 +375,7 @@ static void tapi_transfer_apdu_reply(DBusPendingCall *call, void *user_data)
 	if (apdu_length == 0 || apdu == NULL)
 		DBG("data is NULL");
 
-	DBG("apdu_length %d", apdu_length);
+	DBG("apdu_length %u", apdu_length);
 
 done:
 	ctx->cb(ctx->context, apdu, apdu_length, result);
diff --git a/se/se.c b/se/se.c
index 002498e63f7a..9a8b32ebe6d2 100644
--- a/se/se.c
+++ b/se/se.c
@@ -116,7 +116,7 @@ static void io_cb(void *context,
 	struct seel_se_ioreq *req = context;
 	struct seel_se *se = req->se;
 
-	DBG("%zd %d", apdu_length, err);
+	DBG("%zu %d", apdu_length, err);
 
 	/* Check response status */
 	if (!err)
@@ -247,7 +247,7 @@ static char *se_path(uint32_t se_idx, uint8_t ctrl_idx,
 	if (type == NULL)
 		return NULL;
 
-	return g_strdup_printf("%s/se/%s%d_%s_se%d", SEEL_PATH,
+	return g_strdup_printf("%s/se/%s%u_%s_se%u", SEEL_PATH,
 					ctrl, ctrl_idx, type, se_idx);
 }
 
@@ -538,7 +538,7 @@ static void open_channel_cb(void *context,
 
 	ctx->channel = apdu[0];
 
-	DBG("Channel %d", ctx->channel);
+	DBG("Channel %u", ctx->channel);
 
 	select_aid = __seel_apdu_select_aid(ctx->channel,
 						ctx->aid, ctx->aid_len);
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 31/34] ndef: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (29 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 30/34] se: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 32/34] unit: " Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    src/ndef.c: In function ‘property_get_uri’:
    src/ndef.c:506:31: error: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
      506 |  value = g_strdup_printf("%s%.*s", prefix, uri->field_length,
          |                             ~~^~           ~~~~~~~~~~~~~~~~~
          |                               |               |
          |                               int             uint32_t {aka unsigned int}
    src/ndef.c: In function ‘property_get_uri’:
    src/ndef.c:506:31: error: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
      506 |  value = g_strdup_printf("%s%.*s", prefix, uri->field_length,
          |                             ~~^~           ~~~~~~~~~~~~~~~~~
          |                               |               |
          |                               int             uint32_t {aka unsigned int}

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 src/ndef.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ndef.c b/src/ndef.c
index 0d84ff4dc17b..66faf7867399 100644
--- a/src/ndef.c
+++ b/src/ndef.c
@@ -503,8 +503,8 @@ static gboolean property_get_uri(const GDBusPropertyTable *property,
 
 	DBG("URI prefix %s", prefix);
 
-	value = g_strdup_printf("%s%.*s", prefix, uri->field_length,
-							 uri->field);
+	value = g_strdup_printf("%s%.*s", prefix, (int)uri->field_length,
+				uri->field);
 
 	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &value);
 
@@ -1280,7 +1280,7 @@ parse_uri_payload(uint8_t *payload, uint32_t length)
 	}
 
 	DBG("Identifier  '0X%X'", uri_payload->identifier);
-	DBG("Field  '%.*s'", uri_payload->field_length, uri_payload->field);
+	DBG("Field  '%.*s'", (int)uri_payload->field_length, uri_payload->field);
 
 	return uri_payload;
 
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 32/34] unit: use proper format for integers (-Wformat)
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (30 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 31/34] ndef: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 33/34] build: enable -Wshadow and -Wformat-signedness compiler warnings Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 34/34] AUTHORS: Mention Krzysztof Kozlowski's contributions Krzysztof Kozlowski
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Properly print signed and unsigned integers.  This fixes warnings like:

    unit/test-ndef-parse.c: In function ‘test_ndef_single_sp’:
    unit/test-ndef-parse.c:318:33: error: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 2 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
      318 |   g_print("NDEF SP URI field: %.*s\n", uri->field_length,
          |                               ~~^~     ~~~~~~~~~~~~~~~~~
          |                                 |         |
          |                                 int       uint32_t {aka unsigned int}

    unit/test-snep-read.c: In function ‘test_snep_dummy_req_put’:
    unit/test-snep-read.c:42:12: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
       42 |   g_printf("[SNEP unit] " fmt, ##__VA_ARGS__); \
          |            ^~~~~~~~~~~~~~
    ......
      118 |     frag_cnt, fragment->nfc_data_length,
          |               ~~~~~~~~~~~~~~~~~~~~~~~~~
          |                       |
          |                       uint32_t {aka unsigned int}

    unit/test-snep-read.c: In function ‘test_snep_read_verify_resp’:
    unit/test-snep-read.c:42:12: error: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘int’ [-Werror=format=]
       42 |   g_printf("[SNEP unit] " fmt, ##__VA_ARGS__); \
          |            ^~~~~~~~~~~~~~
    ......
      454 |    resp->response, exp_resp_code);
          |                    ~~~~~~~~~~~~~
          |                    |
          |                    int

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 unit/test-ndef-parse.c | 8 ++++----
 unit/test-snep-read.c  | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/unit/test-ndef-parse.c b/unit/test-ndef-parse.c
index cdeb1a1a24df..0bc53eeac125 100644
--- a/unit/test-ndef-parse.c
+++ b/unit/test-ndef-parse.c
@@ -315,8 +315,8 @@ static void test_ndef_single_sp(void)
 					uri->field_length) == 0);
 
 	if (g_test_verbose())
-		g_print("NDEF SP URI field: %.*s\n", uri->field_length,
-							(char *) uri->field);
+		g_print("NDEF SP URI field: %.*s\n", (int)uri->field_length,
+			(char *) uri->field);
 
 	g_free(uri->field);
 	g_free(uri);
@@ -359,8 +359,8 @@ static void test_ndef_title_sp(void)
 					uri->field_length) == 0);
 
 	if (g_test_verbose())
-		g_print("NDEF SP URI field: %.*s\n", uri->field_length,
-							(char *) uri->field);
+		g_print("NDEF SP URI field: %.*s\n", (int)uri->field_length,
+			(char *) uri->field);
 
 	g_assert_cmpstr(text->data, ==, "Intel");
 	g_assert_cmpstr(text->encoding, ==, "UTF-8");
diff --git a/unit/test-snep-read.c b/unit/test-snep-read.c
index 78db58ba859f..414b801a5e71 100644
--- a/unit/test-snep-read.c
+++ b/unit/test-snep-read.c
@@ -114,7 +114,7 @@ static bool test_snep_dummy_req_put(int fd, void *data)
 		static int frag_cnt;
 		struct p2p_snep_data *fragment = test_fragments->data;
 
-		TEST_SNEP_LOG("\tdummy_req_put frag=%d, len=%d, current=%d\n",
+		TEST_SNEP_LOG("\tdummy_req_put frag=%d, len=%u, current=%u\n",
 				frag_cnt, fragment->nfc_data_length,
 				fragment->nfc_data_current_length);
 		test_fragments = g_slist_remove(test_fragments, fragment);
@@ -437,7 +437,7 @@ static void test_snep_read_no_response(void)
  * @param[in] exp_resp_info_len  Expected response info length
  * @param[in] exp_resp_info      Expected response info
  */
-static void test_snep_read_verify_resp(int exp_resp_code,
+static void test_snep_read_verify_resp(uint8_t exp_resp_code,
 		uint32_t exp_resp_info_len, uint8_t *exp_resp_info)
 {
 	struct p2p_snep_resp_frame *resp;
@@ -467,7 +467,7 @@ static void test_snep_read_verify_resp(int exp_resp_code,
  *
  * @param[in] exp_resp_code  Expected response code
  */
-static void test_snep_read_verify_resp_code(int exp_resp_code)
+static void test_snep_read_verify_resp_code(uint8_t exp_resp_code)
 {
 	test_snep_read_verify_resp(exp_resp_code, 0, NULL);
 }
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 33/34] build: enable -Wshadow and -Wformat-signedness compiler warnings
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (31 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 32/34] unit: " Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 34/34] AUTHORS: Mention Krzysztof Kozlowski's contributions Krzysztof Kozlowski
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Enable code quality warnings - shadowing variables and using wrong
signed data in formats (leading to conversions).

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 accflags.m4 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/accflags.m4 b/accflags.m4
index b1bb1500324f..e4df62c13cf3 100644
--- a/accflags.m4
+++ b/accflags.m4
@@ -22,7 +22,10 @@ AC_DEFUN([NEARD_COMPILER_FLAGS], [
 		AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes], [CFLAGS="$CFLAGS -Wmissing-prototypes"])
 		AX_CHECK_COMPILE_FLAG([-Wjump-misses-init], [CFLAGS="$CFLAGS -Wjump-misses-init"])
 		AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [CFLAGS="$CFLAGS -Wpointer-arith"])
+		AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"])
 
+		# GCC v5.0
+		AX_CHECK_COMPILE_FLAG([-Wformat-signedness], [CFLAGS="$CFLAGS -Wformat-signedness"])
 		# GCC v6.0
 		AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"])
 		AX_CHECK_COMPILE_FLAG([-Wduplicated-cond], [CFLAGS="$CFLAGS -Wduplicated-cond"])
@@ -35,11 +38,7 @@ AC_DEFUN([NEARD_COMPILER_FLAGS], [
 	fi
 	if (test "$USE_MAINTAINER_MODE" = "pedantic"); then
 		AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=3], [CFLAGS="$CFLAGS -Wstrict-overflow=3"])
-		AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"])
 		AX_CHECK_COMPILE_FLAG([-Wcast-qual], [CFLAGS="$CFLAGS -Wcast-qual"])
 		AX_CHECK_COMPILE_FLAG([-Wunsafe-loop-optimizations], [CFLAGS="$CFLAGS -Wunsafe-loop-optimizations"])
-
-		# GCC v5.0
-		AX_CHECK_COMPILE_FLAG([-Wformat-signedness], [CFLAGS="$CFLAGS -Wformat-signedness"])
 	fi
 ])
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [linux-nfc] [neard][PATCH 34/34] AUTHORS: Mention Krzysztof Kozlowski's contributions
  2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
                   ` (32 preceding siblings ...)
  2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 33/34] build: enable -Wshadow and -Wformat-signedness compiler warnings Krzysztof Kozlowski
@ 2021-07-11 20:23 ` Krzysztof Kozlowski
  33 siblings, 0 replies; 35+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-11 20:23 UTC (permalink / raw)
  To: linux-nfc; +Cc: Jakub Kicinski, David S . Miller, Krzysztof Kozlowski

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 AUTHORS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/AUTHORS b/AUTHORS
index 7b60db5e1755..ff8b64624207 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -22,3 +22,4 @@ Mark A. Greer <mgreer@animalcreek.com>
 Arron Wang <arron.wang@intel.com>
 Vincent Cuissard <cuissard@marvell.com>
 Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
+Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> <krzk@kernel.org>
-- 
2.27.0
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2021-07-11 20:29 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-11 20:20 [linux-nfc] [neard][PATCH 00/34] fixes and improvements for neard (continued) Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 01/34] Drop empty NEWS Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 02/34] ci: add building without maintainer options Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 03/34] ci: be verbose when building Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 04/34] ci: add more build configurations (Fedora, Alpine, Debian, cross-compile, i386) Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 05/34] ci: run unit tests Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 06/34] adapter: adjust indentation of continued arguments Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 07/34] ci: display printenv Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 08/34] HACKING: refine required packages Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 09/34] nciattach: fix poll.h include location Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 10/34] unit: use proper pointer to uint8_t in test_snep_read_recv_fragments() Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 11/34] build: fix setting CFLAGS on dash shell (Alpine Linux) Krzysztof Kozlowski
2021-07-11 20:20 ` [linux-nfc] [neard][PATCH 12/34] build: add more compiler warnings Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 13/34] gdbus: do not shadow global 'pending' variable (-Wshadow) Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 14/34] nciattach: do not shadow other local 'opt' " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 15/34] unit: do not shadow global 'uri' " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 16/34] nfctool: use proper format for integers (-Wformat) Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 17/34] bluetooth: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 18/34] ndef: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 19/34] nfctype2: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 20/34] nfctype3: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 21/34] nfctype5: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 22/34] mifare: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 23/34] p2p: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 24/34] npp: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 25/34] adapter: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 26/34] device: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 27/34] manager: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 28/34] tag: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 29/34] netlink: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 30/34] se: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 31/34] ndef: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 32/34] unit: " Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 33/34] build: enable -Wshadow and -Wformat-signedness compiler warnings Krzysztof Kozlowski
2021-07-11 20:23 ` [linux-nfc] [neard][PATCH 34/34] AUTHORS: Mention Krzysztof Kozlowski's contributions Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).