diff mbox series

[2/4] QGA VSS: Replace 'fprintf(stderr' with PRINT_DEBUG

Message ID 20230705141205.525776-3-kkostiuk@redhat.com
State New
Headers show
Series QGA VSS Logging | expand

Commit Message

Konstantin Kostiuk July 5, 2023, 2:12 p.m. UTC
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
---
 qga/vss-win32/install.cpp   | 13 +++++++------
 qga/vss-win32/requester.cpp |  9 +++++----
 2 files changed, 12 insertions(+), 10 deletions(-)

Comments

Philippe Mathieu-Daudé July 5, 2023, 8:36 p.m. UTC | #1
On 5/7/23 16:12, Konstantin Kostiuk wrote:
> Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
> ---
>   qga/vss-win32/install.cpp   | 13 +++++++------
>   qga/vss-win32/requester.cpp |  9 +++++----
>   2 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
> index ff93b08a9e..c10a397e51 100644
> --- a/qga/vss-win32/install.cpp
> +++ b/qga/vss-win32/install.cpp
> @@ -13,6 +13,7 @@
>   #include "qemu/osdep.h"
>   
>   #include "vss-common.h"
> +#include "vss-debug.h"
>   #ifdef HAVE_VSS_SDK
>   #include <vscoordint.h>
>   #else
> @@ -54,7 +55,7 @@ void errmsg(DWORD err, const char *text)
>                     FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
>                     NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
>                     (char *)&msg, 0, NULL);
> -    fprintf(stderr, "%.*s. (Error: %lx) %s\n", len, text, err, msg);
> +    PRINT_DEBUG("%.*s. (Error: %lx) %s\n", len, text, err, msg);

PRINT_DEBUG() ends calling fprintf(stderr)...
Konstantin Kostiuk July 6, 2023, 8:36 a.m. UTC | #2
On Wed, Jul 5, 2023 at 11:36 PM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:

> On 5/7/23 16:12, Konstantin Kostiuk wrote:
> > Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
> > ---
> >   qga/vss-win32/install.cpp   | 13 +++++++------
> >   qga/vss-win32/requester.cpp |  9 +++++----
> >   2 files changed, 12 insertions(+), 10 deletions(-)
> >
> > diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
> > index ff93b08a9e..c10a397e51 100644
> > --- a/qga/vss-win32/install.cpp
> > +++ b/qga/vss-win32/install.cpp
> > @@ -13,6 +13,7 @@
> >   #include "qemu/osdep.h"
> >
> >   #include "vss-common.h"
> > +#include "vss-debug.h"
> >   #ifdef HAVE_VSS_SDK
> >   #include <vscoordint.h>
> >   #else
> > @@ -54,7 +55,7 @@ void errmsg(DWORD err, const char *text)
> >                     FORMAT_MESSAGE_FROM_SYSTEM |
> FORMAT_MESSAGE_IGNORE_INSERTS,
> >                     NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
> >                     (char *)&msg, 0, NULL);
> > -    fprintf(stderr, "%.*s. (Error: %lx) %s\n", len, text, err, msg);
> > +    PRINT_DEBUG("%.*s. (Error: %lx) %s\n", len, text, err, msg);
>
> PRINT_DEBUG() ends calling fprintf(stderr)...
>
>
Yes, PRINT_DEBUG calling fprintf(stderr).
This patch replaces fprintf(stderr call from errmsg with PRINT_DEBUG.

What do you mean by this comment?
diff mbox series

Patch

diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index ff93b08a9e..c10a397e51 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -13,6 +13,7 @@ 
 #include "qemu/osdep.h"
 
 #include "vss-common.h"
+#include "vss-debug.h"
 #ifdef HAVE_VSS_SDK
 #include <vscoordint.h>
 #else
@@ -54,7 +55,7 @@  void errmsg(DWORD err, const char *text)
                   FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                   NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                   (char *)&msg, 0, NULL);
-    fprintf(stderr, "%.*s. (Error: %lx) %s\n", len, text, err, msg);
+    PRINT_DEBUG("%.*s. (Error: %lx) %s\n", len, text, err, msg);
     LocalFree(msg);
 }
 
@@ -219,7 +220,7 @@  static HRESULT QGAProviderRemove(ICatalogCollection *coll, int i, void *arg)
 {
     HRESULT hr;
 
-    fprintf(stderr, "Removing COM+ Application: %s\n", QGA_PROVIDER_NAME);
+    PRINT_DEBUG("Removing COM+ Application: %s", QGA_PROVIDER_NAME);
     chk(coll->Remove(i));
 out:
     return hr;
@@ -304,9 +305,9 @@  STDAPI COMRegister(void)
     }
     strcpy(tlbPath, dllPath);
     strcpy(tlbPath+n-3, "tlb");
-    fprintf(stderr, "Registering " QGA_PROVIDER_NAME ":\n");
-    fprintf(stderr, "  %s\n", dllPath);
-    fprintf(stderr, "  %s\n", tlbPath);
+    PRINT_DEBUG("Registering " QGA_PROVIDER_NAME ":");
+    PRINT_DEBUG("  %s", dllPath);
+    PRINT_DEBUG("  %s", tlbPath);
     if (!PathFileExists(tlbPath)) {
         hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
         errmsg(hr, "Failed to lookup tlb");
@@ -517,7 +518,7 @@  namespace _com_util
         }
 
         if (mbstowcs(bstr, ascii, len) == (size_t)-1) {
-            fprintf(stderr, "Failed to convert string '%s' into BSTR", ascii);
+            PRINT_DEBUG("Failed to convert string '%s' into BSTR", ascii);
             bstr[0] = 0;
         }
         return bstr;
diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp
index 3e998af4a8..e4f7013c62 100644
--- a/qga/vss-win32/requester.cpp
+++ b/qga/vss-win32/requester.cpp
@@ -12,6 +12,7 @@ 
 
 #include "qemu/osdep.h"
 #include "vss-common.h"
+#include "vss-debug.h"
 #include "requester.h"
 #include "install.h"
 #include <vswriter.h>
@@ -59,13 +60,13 @@  STDAPI requester_init(void)
         NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
         RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL);
     if (FAILED(hr)) {
-        fprintf(stderr, "failed to CoInitializeSecurity (error %lx)\n", hr);
+        PRINT_DEBUG("failed to CoInitializeSecurity (error %lx)", hr);
         return hr;
     }
 
     hLib = LoadLibraryA("VSSAPI.DLL");
     if (!hLib) {
-        fprintf(stderr, "failed to load VSSAPI.DLL\n");
+        PRINT_DEBUG("failed to load VSSAPI.DLL");
         return HRESULT_FROM_WIN32(GetLastError());
     }
 
@@ -78,14 +79,14 @@  STDAPI requester_init(void)
 #endif
         );
     if (!pCreateVssBackupComponents) {
-        fprintf(stderr, "failed to get proc address from VSSAPI.DLL\n");
+        PRINT_DEBUG("failed to get proc address from VSSAPI.DLL");
         return HRESULT_FROM_WIN32(GetLastError());
     }
 
     pVssFreeSnapshotProperties = (t_VssFreeSnapshotProperties)
         GetProcAddress(hLib, "VssFreeSnapshotProperties");
     if (!pVssFreeSnapshotProperties) {
-        fprintf(stderr, "failed to get proc address from VSSAPI.DLL\n");
+        PRINT_DEBUG("failed to get proc address from VSSAPI.DLL");
         return HRESULT_FROM_WIN32(GetLastError());
     }