]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Explain why realloc_size_zero does not use Addr.Block and clean up a volatile cast
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 1 Mar 2026 17:19:46 +0000 (18:19 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 1 Mar 2026 17:19:46 +0000 (18:19 +0100)
coregrind/m_syswrap/syswrap-freebsd.c
memcheck/mc_errors.c

index c2e2f50dc9588547021e5f14efe430b9af42153a..c9a393947840ff6be959bbf5eef65a1ce534b9af 100644 (file)
@@ -7026,15 +7026,7 @@ PRE(sys_aio_readv)
          SET_STATUS_Failure( VKI_EBADF );
       } else {
          SizeT vec_count = (SizeT)iocb->aio_nbytes;
-#if defined(__clang__)
-#pragma clang diagnostic push
-         // yes, I know it is volatile
-#pragma clang diagnostic ignored "-Wcast-qual"
-#endif
-         struct vki_iovec* p_iovec  = (struct vki_iovec*)iocb->aio_buf;
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
+         struct vki_iovec* p_iovec  = (struct vki_iovec*)(uintptr_t)iocb->aio_buf;
          PRE_MEM_READ("aio_readv(iocb->aio_iov)", (Addr)p_iovec,  vec_count*sizeof(struct vki_iovec));
          if (ML_(safe_to_deref)(p_iovec, vec_count*sizeof(struct vki_iovec))) {
             for (SizeT i = 0U; i < vec_count; ++i) {
index e9a8f3f02eb6615bd7871c2cecb15b5113dd91af..b8869733fd732985ca3b1768d465016e2c934318 100644 (file)
@@ -1014,6 +1014,15 @@ void MC_(record_realloc_size_zero) ( ThreadId tid, Addr a )
 {
    MC_Error extra;
    tl_assert(VG_INVALID_THREADID != tid);
+   /*
+    * We can't fill the Block as in freemismatch above.
+    * That's because if realloc size zero frees we literally do that
+    * and transform the call into a free before bothering to get the
+    * old MC_Chunk.
+    *
+    * See VG_(maybe_record_error) for a description of how this gets
+    * filled on demand.
+    */
    extra.Err.ReallocSizeZero.ai.tag = Addr_Undescribed;
    VG_(maybe_record_error)( tid, Err_ReallocSizeZero, a, /*s*/NULL, &extra );
 }