From 79ebd337d791f260e26e5b3decdff145954c8c5c Mon Sep 17 00:00:00 2001 From: Bernard Teo Date: Wed, 18 Sep 2024 22:51:17 -0600 Subject: [PATCH] GTK, Portal: Fix variable shadowing warnings (#150) --- .github/workflows/cmake.yml | 10 +++++----- src/nfd_gtk.cpp | 3 +-- src/nfd_portal.cpp | 16 ++++++++-------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b1a011a..c8c808c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -75,7 +75,7 @@ jobs: - name: Install Dependencies run: sudo apt-get update && sudo apt-get install ${{ matrix.portal.dep }} - name: Configure - run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${{ matrix.compiler.c }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }} -DCMAKE_CXX_STANDARD=${{ matrix.cppstd }} -DCMAKE_C_FLAGS="-Wall -Wextra -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_APPEND_EXTENSION=${{ matrix.autoappend.flag }} -DBUILD_SHARED_LIBS=${{ matrix.shared_lib.flag }} -DNFD_BUILD_TESTS=ON .. + run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${{ matrix.compiler.c }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }} -DCMAKE_CXX_STANDARD=${{ matrix.cppstd }} -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_APPEND_EXTENSION=${{ matrix.autoappend.flag }} -DBUILD_SHARED_LIBS=${{ matrix.shared_lib.flag }} -DNFD_BUILD_TESTS=ON .. - name: Build run: cmake --build build --target install - name: Upload test binaries @@ -100,7 +100,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Configure - run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror -pedantic" -DBUILD_SHARED_LIBS=${{ matrix.shared_lib.flag }} -DNFD_BUILD_TESTS=ON .. + run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DBUILD_SHARED_LIBS=${{ matrix.shared_lib.flag }} -DNFD_BUILD_TESTS=ON .. - name: Build run: cmake --build build --target install - name: Upload test binaries @@ -176,7 +176,7 @@ jobs: mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake - name: Configure - run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror -pedantic" -DNFD_BUILD_TESTS=ON .. + run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_BUILD_TESTS=ON .. - name: Build run: cmake --build build --target install - name: Upload test binaries @@ -202,7 +202,7 @@ jobs: - name: Install Dependencies run: sudo apt-get update && sudo apt-get install ${{ matrix.portal.dep }} libsdl2-dev libsdl2-ttf-dev - name: Configure - run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_APPEND_EXTENSION=OFF -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_SDL2_TESTS=ON .. + run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_PORTAL=${{ matrix.portal.flag }} -DNFD_APPEND_EXTENSION=OFF -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_SDL2_TESTS=ON .. - name: Build run: cmake --build build --target install - name: Upload test binaries @@ -224,7 +224,7 @@ jobs: - name: Install Dependencies run: brew install sdl2 sdl2_ttf - name: Configure - run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror -pedantic" -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_SDL2_TESTS=ON .. + run: mkdir build && mkdir install && cd build && cmake -DCMAKE_INSTALL_PREFIX="../install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wshadow -Werror -pedantic" -DNFD_BUILD_TESTS=OFF -DNFD_BUILD_SDL2_TESTS=ON .. - name: Build run: cmake --build build --target install - name: Upload test binaries diff --git a/src/nfd_gtk.cpp b/src/nfd_gtk.cpp index 86aa797..bdb6292 100644 --- a/src/nfd_gtk.cpp +++ b/src/nfd_gtk.cpp @@ -447,8 +447,7 @@ void RealizedSignalHandler(GtkWidget* window, void* userdata) { } struct NativeWindowParenter { - NativeWindowParenter(GtkWidget* widget, const nfdwindowhandle_t& parentWindow) noexcept - : widget(widget) { + NativeWindowParenter(GtkWidget* w, const nfdwindowhandle_t& parentWindow) noexcept : widget(w) { parent = GetAllocNativeWindowHandle(parentWindow); if (parent) { diff --git a/src/nfd_portal.cpp b/src/nfd_portal.cpp index 77fd5d5..684c502 100644 --- a/src/nfd_portal.cpp +++ b/src/nfd_portal.cpp @@ -1605,17 +1605,17 @@ nfdresult_t NFD_PickFolderN_With_Impl(nfdversion_t version, (void)version; { - dbus_uint32_t version; - const nfdresult_t res = NFD_DBus_GetVersion(version); + dbus_uint32_t portal_version; + const nfdresult_t res = NFD_DBus_GetVersion(portal_version); if (res != NFD_OKAY) { return res; } - if (version < 3) { + if (portal_version < 3) { NFDi_SetFormattedError( "The xdg-desktop-portal installed on this system does not support a folder picker; " "at least version 3 of the org.freedesktop.portal.FileChooser interface is " "required but the installed interface version is %u.", - version); + portal_version); return NFD_ERROR; } } @@ -1662,17 +1662,17 @@ nfdresult_t NFD_PickFolderMultipleN_With_Impl(nfdversion_t version, (void)version; { - dbus_uint32_t version; - const nfdresult_t res = NFD_DBus_GetVersion(version); + dbus_uint32_t portal_version; + const nfdresult_t res = NFD_DBus_GetVersion(portal_version); if (res != NFD_OKAY) { return res; } - if (version < 3) { + if (portal_version < 3) { NFDi_SetFormattedError( "The xdg-desktop-portal installed on this system does not support a folder picker; " "at least version 3 of the org.freedesktop.portal.FileChooser interface is " "required but the installed interface version is %u.", - version); + portal_version); return NFD_ERROR; } }