intel: Avoid aliasing violation

../intel/test_decode.c: In function ‘compare_batch’:
../intel/test_decode.c:109:39: error: dereferencing type-punned pointer might break strict-aliasing rules [-Werror=strict-aliasing]
  109 |         out = open_memstream((char **)&ptr, &size);
      |                                       ^~~~
cc1: some warnings being treated as errors

The fix is simple: just declare `ptr` as a `char *` to begin with.
main
Matt Turner 2022-08-22 21:36:52 -04:00
parent 3ff3d59ed9
commit d4bb19e2c4
1 changed files with 3 additions and 2 deletions

View File

@ -86,7 +86,8 @@ static void
compare_batch(struct drm_intel_decode *ctx, const char *batch_filename)
{
FILE *out = NULL;
void *ptr, *ref_ptr, *batch_ptr;
char *ptr;
void *ref_ptr, *batch_ptr;
#if HAVE_OPEN_MEMSTREAM
size_t size;
#endif
@ -106,7 +107,7 @@ compare_batch(struct drm_intel_decode *ctx, const char *batch_filename)
* inside of an automake project's test infrastructure.
*/
#if HAVE_OPEN_MEMSTREAM
out = open_memstream((char **)&ptr, &size);
out = open_memstream(&ptr, &size);
#else
fprintf(stderr, "platform lacks open_memstream, skipping.\n");
exit(77);