pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/mpaland/printf/pull/58/commits/ccf61490b52208fcc744b92bbd6d9ab5974d700e

="https://github.githubassets.com/assets/global-d10a1ef1d5e1.css" /> Unittest redesign by ledvinap · Pull Request #58 · mpaland/printf · GitHub
Skip to content
Prev Previous commit
Use preprocessor to handle %p size
  • Loading branch information
ledvinap committed Jun 5, 2019
commit ccf61490b52208fcc744b92bbd6d9ab5974d700e
15 changes: 5 additions & 10 deletions printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <stdbool.h>
#include <stdint.h>
#include <limits.h>

#include "printf.h"

Expand Down Expand Up @@ -822,16 +823,10 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
case 'p' : {
width = sizeof(void*) * 2U;
flags |= FLAGS_ZEROPAD | FLAGS_UPPERCASE;
#if defined(PRINTF_SUPPORT_LONG_LONG)
const bool is_ll = sizeof(uintptr_t) == sizeof(long long);
if (is_ll) {
idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)va_arg(va, void*), false, 16U, precision, width, flags);
}
else {
#endif
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)va_arg(va, void*)), false, 16U, precision, width, flags);
#if defined(PRINTF_SUPPORT_LONG_LONG)
}
#if defined(PRINTF_SUPPORT_LONG_LONG) && (LONG_MAX < UINTPTR_MAX)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should be if defined(PRINTF_SUPPORT_LONG_LONG) && (ULONG_MAX < UINTPTR_MAX). The current test selects the long long code even for 32-bit pointers on targets with 32-bit longs as LONG_MAX < ULONG_MAX is always true. Writing this comparison as (UINTPTR_MAX > ULONG_MAX) might be more readable.

idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)va_arg(va, void*), false, 16U, precision, width, flags);
#else
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)va_arg(va, void*)), false, 16U, precision, width, flags);
#endif
format++;
break;
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy