[v4,7/7] egl/main: use cross platform implementation 'util_vsnprintf'

Submitted by andrey simiklit on Sept. 6, 2018, 2:43 p.m.

Details

Message ID 1536245039-22231-8-git-send-email-asimiklit.work@gmail.com
State New
Headers show
Series "mesa/util: add missing va_end() after va_copy()" ( rev: 10 ) in Mesa

Not browsing as part of any series.

Commit Message

andrey simiklit Sept. 6, 2018, 2:43 p.m.
From: Andrii Simiklit <andrii.simiklit@globallogic.com>

I guess it makes this implementation more portable.

Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
---
 src/amd/vulkan/radv_util.c | 5 +++--
 src/egl/main/egllog.c      | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/vulkan/radv_util.c b/src/amd/vulkan/radv_util.c
index 72bedc6..90d3824 100644
--- a/src/amd/vulkan/radv_util.c
+++ b/src/amd/vulkan/radv_util.c
@@ -33,6 +33,7 @@ 
 #include "vk_enum_to_str.h"
 
 #include "util/u_math.h"
+#include "util/u_string.h"
 
 /** Log an error message.  */
 void radv_printflike(1, 2)
@@ -81,7 +82,7 @@  void radv_printflike(3, 4)
 	char buffer[256];
 
 	va_start(ap, format);
-	vsnprintf(buffer, sizeof(buffer), format, ap);
+	util_vsnprintf(buffer, sizeof(buffer), format, ap);
 	va_end(ap);
 
 	fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer);
@@ -103,7 +104,7 @@  __vk_errorf(struct radv_instance *instance, VkResult error, const char *file,
 
 	if (format) {
 		va_start(ap, format);
-		vsnprintf(buffer, sizeof(buffer), format, ap);
+		util_vsnprintf(buffer, sizeof(buffer), format, ap);
 		va_end(ap);
 
 		fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);
diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
index c223f49..d21b070 100644
--- a/src/egl/main/egllog.c
+++ b/src/egl/main/egllog.c
@@ -42,6 +42,7 @@ 
 #include <strings.h>
 #include "c11/threads.h"
 #include "util/macros.h"
+#include "util/u_string.h"
 
 #include "egllog.h"
 
@@ -154,7 +155,7 @@  _eglLog(EGLint level, const char *fmtStr, ...)
    mtx_lock(&logging.mutex);
 
    va_start(args, fmtStr);
-   ret = vsnprintf(msg, MAXSTRING, fmtStr, args);
+   ret = util_vsnprintf(msg, MAXSTRING, fmtStr, args);
    if (ret < 0 || ret >= MAXSTRING)
       strcpy(msg, "<message truncated>");
    va_end(args);

Comments

On 09/06/2018 07:43 AM, asimiklit.work@gmail.com wrote:
> From: Andrii Simiklit <andrii.simiklit@globallogic.com>
> 
> I guess it makes this implementation more portable.
> 
> Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
> ---
>  src/amd/vulkan/radv_util.c | 5 +++--
>  src/egl/main/egllog.c      | 3 ++-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/amd/vulkan/radv_util.c b/src/amd/vulkan/radv_util.c
> index 72bedc6..90d3824 100644
> --- a/src/amd/vulkan/radv_util.c
> +++ b/src/amd/vulkan/radv_util.c

I guess these changes were supposed to be in the next patch?

> @@ -33,6 +33,7 @@
>  #include "vk_enum_to_str.h"
>  
>  #include "util/u_math.h"
> +#include "util/u_string.h"
>  
>  /** Log an error message.  */
>  void radv_printflike(1, 2)
> @@ -81,7 +82,7 @@ void radv_printflike(3, 4)
>  	char buffer[256];
>  
>  	va_start(ap, format);
> -	vsnprintf(buffer, sizeof(buffer), format, ap);
> +	util_vsnprintf(buffer, sizeof(buffer), format, ap);
>  	va_end(ap);
>  
>  	fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer);
> @@ -103,7 +104,7 @@ __vk_errorf(struct radv_instance *instance, VkResult error, const char *file,
>  
>  	if (format) {
>  		va_start(ap, format);
> -		vsnprintf(buffer, sizeof(buffer), format, ap);
> +		util_vsnprintf(buffer, sizeof(buffer), format, ap);
>  		va_end(ap);
>  
>  		fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);
> diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
> index c223f49..d21b070 100644
> --- a/src/egl/main/egllog.c
> +++ b/src/egl/main/egllog.c
> @@ -42,6 +42,7 @@
>  #include <strings.h>
>  #include "c11/threads.h"
>  #include "util/macros.h"
> +#include "util/u_string.h"
>  
>  #include "egllog.h"
>  
> @@ -154,7 +155,7 @@ _eglLog(EGLint level, const char *fmtStr, ...)
>     mtx_lock(&logging.mutex);
>  
>     va_start(args, fmtStr);
> -   ret = vsnprintf(msg, MAXSTRING, fmtStr, args);
> +   ret = util_vsnprintf(msg, MAXSTRING, fmtStr, args);
>     if (ret < 0 || ret >= MAXSTRING)
>        strcpy(msg, "<message truncated>");
>     va_end(args);
>
On Fri, Sep 7, 2018 at 5:40 AM Ian Romanick <idr@freedesktop.org> wrote:

> On 09/06/2018 07:43 AM, asimiklit.work@gmail.com wrote:
> > From: Andrii Simiklit <andrii.simiklit@globallogic.com>
> >
> > I guess it makes this implementation more portable.
> >
> > Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
> > ---
> >  src/amd/vulkan/radv_util.c | 5 +++--
> >  src/egl/main/egllog.c      | 3 ++-
> >  2 files changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/amd/vulkan/radv_util.c b/src/amd/vulkan/radv_util.c
> > index 72bedc6..90d3824 100644
> > --- a/src/amd/vulkan/radv_util.c
> > +++ b/src/amd/vulkan/radv_util.c
>
> I guess these changes were supposed to be in the next patch?
>

Oh it is my fail I forgot to remove this from patches folder.
It is just duplicate for:
[PATCH v4 8/8] egl/main: use cross platform implementation 'util_vsnprintf'
[PATCH v4 7/8] radv: use cross platform implementation 'util_vsnprintf'

Thanks for pointing out my mistake.
Just ignore this patch.


> > @@ -33,6 +33,7 @@
> >  #include "vk_enum_to_str.h"
> >
> >  #include "util/u_math.h"
> > +#include "util/u_string.h"
> >
> >  /** Log an error message.  */
> >  void radv_printflike(1, 2)
> > @@ -81,7 +82,7 @@ void radv_printflike(3, 4)
> >       char buffer[256];
> >
> >       va_start(ap, format);
> > -     vsnprintf(buffer, sizeof(buffer), format, ap);
> > +     util_vsnprintf(buffer, sizeof(buffer), format, ap);
> >       va_end(ap);
> >
> >       fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer);
> > @@ -103,7 +104,7 @@ __vk_errorf(struct radv_instance *instance, VkResult
> error, const char *file,
> >
> >       if (format) {
> >               va_start(ap, format);
> > -             vsnprintf(buffer, sizeof(buffer), format, ap);
> > +             util_vsnprintf(buffer, sizeof(buffer), format, ap);
> >               va_end(ap);
> >
> >               fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer,
> error_str);
> > diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
> > index c223f49..d21b070 100644
> > --- a/src/egl/main/egllog.c
> > +++ b/src/egl/main/egllog.c
> > @@ -42,6 +42,7 @@
> >  #include <strings.h>
> >  #include "c11/threads.h"
> >  #include "util/macros.h"
> > +#include "util/u_string.h"
> >
> >  #include "egllog.h"
> >
> > @@ -154,7 +155,7 @@ _eglLog(EGLint level, const char *fmtStr, ...)
> >     mtx_lock(&logging.mutex);
> >
> >     va_start(args, fmtStr);
> > -   ret = vsnprintf(msg, MAXSTRING, fmtStr, args);
> > +   ret = util_vsnprintf(msg, MAXSTRING, fmtStr, args);
> >     if (ret < 0 || ret >= MAXSTRING)
> >        strcpy(msg, "<message truncated>");
> >     va_end(args);
> >
>
>