This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=c8bd356d3efca0ef81dd3b7624fec16016c99c1b

commit c8bd356d3efca0ef81dd3b7624fec16016c99c1b
Author: Guillem Jover <[email protected]>
AuthorDate: Sun Jun 25 01:42:50 2023 +0200

    libcompat: Use ptrdiff_t directly instead of using a macro
    
    We can include <stddef.h> and that does not pollute anything. This
    simplifies the code and avoids confusing static analyzers.
    
    Warned-by: cppcheck
---
 lib/compat/obstack.h | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/lib/compat/obstack.h b/lib/compat/obstack.h
index 8bed79315..1818127bf 100644
--- a/lib/compat/obstack.h
+++ b/lib/compat/obstack.h
@@ -105,22 +105,12 @@ Summary:
 #ifndef _OBSTACK_H
 #define _OBSTACK_H 1
 
+# include <stddef.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* We need the type of a pointer subtraction.  If __PTRDIFF_TYPE__ is
-   defined, as with GNU C, use that; that way we don't pollute the
-   namespace with <stddef.h>'s symbols.  Otherwise, include <stddef.h>
-   and use ptrdiff_t.  */
-
-#ifdef __PTRDIFF_TYPE__
-# define PTR_INT_TYPE __PTRDIFF_TYPE__
-#else
-# include <stddef.h>
-# define PTR_INT_TYPE ptrdiff_t
-#endif
-
 /* If B is the base of an object addressed by P, return the result of
    aligning P to the next multiple of A + 1.  B and P must be of type
    char *.  A + 1 must be a power of 2.  */
@@ -129,13 +119,13 @@ extern "C" {
 
 /* Similar to _BPTR_ALIGN (B, P, A), except optimize the common case
    where pointers can be converted to integers, aligned as integers,
-   and converted back again.  If PTR_INT_TYPE is narrower than a
+   and converted back again.  If ptrdiff_t is narrower than a
    pointer (e.g., the AS/400), play it safe and compute the alignment
    relative to B.  Otherwise, use the faster strategy of computing the
    alignment relative to 0.  */
 
 #define __PTR_ALIGN(B, P, A)                                               \
-  __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \
+  __BPTR_ALIGN (sizeof (ptrdiff_t) < sizeof (void *) ? (B) : (char *) 0, \
                P, A)
 
 #include <string.h>
@@ -156,7 +146,7 @@ struct obstack              /* control current object in 
current chunk */
   char *chunk_limit;           /* address of char after current chunk */
   union
   {
-    PTR_INT_TYPE tempint;
+    ptrdiff_t tempint;
     void *tempptr;
   } temp;                      /* Temporary for some macros.  */
   size_t alignment_mask;       /* Mask of alignment for each object. */

-- 
Dpkg.Org's dpkg

Reply via email to