gdk/win32: fix `hr` set but not used
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 25 Apr 2023 12:18:26 +0000 (16:18 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 25 Apr 2023 12:37:58 +0000 (16:37 +0400)
A number of warnings are produced:

[23/1038] Compiling C object gdk/win32/libgdk-win32.a.p/gdkinput-dmanipulation.c.obj
../gdk/win32/gdkinput-dmanipulation.c: In function 'reset_viewport':
../gdk/win32/gdkinput-dmanipulation.c:354:11: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
  354 |   HRESULT hr;
      |           ^~

Try to do something sensible instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
gdk/win32/gdkinput-dmanipulation.c
gdk/win32/gdkprivate-win32.h

index 942db6cdc280f62e932c65987e1e8d34c937c60b..fe3215a3fb4bd2e8fc046faee908e7586d30ec3e 100644 (file)
@@ -354,12 +354,13 @@ reset_viewport (IDirectManipulationViewport *viewport)
   HRESULT hr;
 
   hr = IDirectManipulationViewport_GetPrimaryContent (viewport, iid, (void**)&content);
-  HR_CHECK (hr);
+  HR_CHECK_GOTO (hr, failed);
 
   hr = IDirectManipulationContent_SyncContentTransform (content, identity,
                                                         G_N_ELEMENTS (identity));
-  HR_CHECK (hr);
+  HR_CHECK_GOTO (hr, failed);
 
+failed:
   IUnknown_Release (content);
 }
 
@@ -384,7 +385,7 @@ create_viewport (GdkSurface *surface,
 {
   DIRECTMANIPULATION_CONFIGURATION configuration = 0;
   HWND hwnd = GDK_SURFACE_HWND (surface);
-  IDirectManipulationViewportEventHandler *handler;
+  IDirectManipulationViewportEventHandler *handler = NULL;
   DWORD cookie = 0;
   HRESULT hr;
 
@@ -500,7 +501,7 @@ void gdk_dmanipulation_initialize_surface (GdkSurface *surface)
 
   hr = IDirectManipulationManager_Activate (dmanipulation_manager,
                                             GDK_SURFACE_HWND (surface));
-  HR_CHECK (hr);
+  HR_CHECK_RETURN (hr);
 }
 
 void gdk_dmanipulation_finalize_surface (GdkSurface *surface)
@@ -536,11 +537,11 @@ void gdk_dmanipulation_maybe_add_contact (GdkSurface *surface,
 
       hr = IDirectManipulationViewport_SetContact (surface_win32->dmanipulation_viewport_pan,
                                                    pointer_id);
-      HR_CHECK (hr);
+      HR_CHECK_RETURN (hr);
 
       hr = IDirectManipulationViewport_SetContact (surface_win32->dmanipulation_viewport_zoom,
                                                    pointer_id);
-      HR_CHECK (hr);
+      HR_CHECK_RETURN (hr);
     }
 }
 
index acde8a058c9c89cc10bca650a9bcc9ea1ceef865..3452a8e55f5167caf201878437c9a08083c0a00c 100644 (file)
@@ -276,7 +276,6 @@ void    _gdk_other_api_failed        (const char *where,
 
 #define HR_CHECK_RETURN(hr) { if G_UNLIKELY (FAILED (hr)) return; }
 #define HR_CHECK_RETURN_VAL(hr, val) { if G_UNLIKELY (FAILED (hr)) return val; }
-#define HR_CHECK(hr)
 #define HR_CHECK_GOTO(hr, label) { if G_UNLIKELY (FAILED (hr)) goto label; }
 
 extern LRESULT CALLBACK _gdk_win32_surface_procedure (HWND, UINT, WPARAM, LPARAM);