search for: size_max

Displaying 20 results from an estimated 265 matches for "size_max".

2013 Apr 06
2
Circular preprocessor define with MSVC
Hi, in include/share/alloc.h there is this section: #ifndef SIZE_MAX # ifndef SIZE_T_MAX # ifdef _MSC_VER # define SIZE_T_MAX SIZE_MAX # else # error # endif # endif # define SIZE_MAX SIZE_T_MAX #endif So, if we are on MSVC and have neither SIZE_MAX nor SIZE_T_MAX, we'll define SIZE_T_MAX to mean SIZE_MAX and SIZE_MAX to mean SIZE_T_MAX. I'm afra...
2008 Aug 13
4
MinGW Patch
Hello, I was trying to compile Flac on MinGW/Msys but got an error stating SIZE_T_MAX is undefined. To fix this error I edited the file "flac-1.2.1/include/share/alloc.h" and made the following change: Starting at line #36 I changed: #ifndef SIZE_MAX # ifndef SIZE_T_MAX # ifdef _MSC_VER # define SIZE_T_MAX UINT_MAX # else # error # endif # endif # define SIZE_MAX SIZE_T_MAX #endif To: #ifndef SIZE_MAX # ifndef SIZE_T_MAX # ifdef _MSC_VER # define SIZE_T_MAX UINT_MAX # elif defined(__MINGW_H) # define SIZE_T_MAX UINT_MAX # else #...
2016 Jul 13
2
[PATCH v3 1/7] lib: string: add functions to case-convert strings
...nclude/linux/string.h, and I don't see any include path mentioning > kernel.h, where do you see the circular dependency? I might be missing > something. I did some more poking around and this is what I found. For starters, the problem happens with kernel/bounds.c. Without worrying about SIZE_MAX or making any other changes, I added a #warning line to kernel.h and string.h to see the include sequence. $ aarch64-linux-gcc -Wp,-MD,kernel/.bounds.s.d -nostdinc -isystem /opt/toolchain/stbgcc-4.8-1.5/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/include -I./arch/arm64/include -Iarch/arm64/include/gen...
2011 Aug 02
0
[LLVMdev] "icmp sgt" when it should be "ugt" ?
...ur proposed scenario, the GEP returns undef. > > by the way, is GEP arithmetic supposed to be signed or unsigned? It's a mix of both. Indices are signed, but the other operand is a pointer, and pointers can be interpreted in a variety of ways. On one hand, pointers are unsigned, since SIZE_MAX/2 and SIZE_MAX/2+1 are contiguous addresses, while SIZE_MAX and SIZE_MAX+1 are not, because address 0 is special. On the other hand, it's generally considered to be impossible to allocate more than half the address space to a single object, so it often works to analyze them as if they were sign...
2016 Jul 13
0
[PATCH v3 1/7] lib: string: add functions to case-convert strings
...#39;t see any include path mentioning >> kernel.h, where do you see the circular dependency? I might be missing >> something. > > I did some more poking around and this is what I found. > > For starters, the problem happens with kernel/bounds.c. Without > worrying about SIZE_MAX or making any other changes, I added a > #warning line to kernel.h and string.h to see the include sequence. > > $ aarch64-linux-gcc -Wp,-MD,kernel/.bounds.s.d -nostdinc -isystem > /opt/toolchain/stbgcc-4.8-1.5/bin/../lib/gcc/aarch64-linux-gnu/4.8.5/include > -I./arch/arm64/include...
2017 May 02
1
libFLAC with Android NDK: use of undeclared identifier 'SIZE_MAX'
Hi flac-dev, When we try to build libFLAC v1.3.1 using the Android NDK, we currently are getting an error in a couple files: ../../third_party/flac/src/libFLAC/md5.c:498:25: error: use of undeclared > identifier 'SIZE_MAX' > if ((size_t)channels > SIZE_MAX / (size_t)bytes_per_sample) > I filed a bug for it on the sourceforge bug tracker: https://sourceforge.net/p/flac/bugs/457/ This is fixed (in all NDK versions) by including limits.h. I've attached a simple patch that fixes the Android NDK build...
2024 Sep 11
2
[Bug 3734] New: Expression 'l > SIZE_MAX' is always false
https://bugzilla.mindrot.org/show_bug.cgi?id=3734 Bug ID: 3734 Summary: Expression 'l > SIZE_MAX' is always false Product: Portable OpenSSH Version: 9.8p1 Hardware: Other OS: All Status: NEW Severity: enhancement Priority: P5 Component: Build system Assignee: unassigned-bugs at mindrot.org...
2011 Aug 02
3
[LLVMdev] "icmp sgt" when it should be "ugt" ?
Hi Eli, >>> Icmp sgt is correct. >> >> while ugt would be wrong, I think sgt is too! >> >> For example, suppose %buf is 0 and %bufLen is ~0U. Then %add.ptr is ~0U, and >> %cmp is true, so control branches to %if.then. However in the optimized version >> %cmp is false and control branches to %if.end. >> >> The GEP does have an inbounds
2023 May 10
3
[PATCH] virtio_ring: use u32 for virtio_max_dma_size
...see struct vring_desc and struct vring_packed_desc. This means the max segment size supported by virtio is U32_MAX. An example of virtio_max_dma_size in virtio_blk.c: u32 v, max_size; max_size = virtio_max_dma_size(vdev); -> implicit convert err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SIZE_MAX, struct virtio_blk_config, size_max, &v); max_size = min(max_size, v); There is a risk during implicit convert here, once virtio_max_dma_size returns 4G, max_size becomes 0. Fixes: e6d6dd6c875e ("virtio: Introduce virtio_max_dma_size()") Cc: Joerg Roed...
2008 May 10
3
Patch : Fix cross-compiling from Linux to windows
Hi all, The following patch fixes cross compiling from Linux to windows. The existing code was doing: #if !defined _MSC_VER && !defined __MINGW32__ && !defined __EMX__ #include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */ #endif when it seems to make much more sense to just test for the presence of <stdint.h> and do: #ifdef HAVE_STDINT_H #include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */ #endif It is not possible to cross com...
2012 Sep 08
3
[patch 1/3] xen/privcmd: check for integer overflow in ioctl
...c b/drivers/xen/privcmd.c index 215a3c0..fdff8f9 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -325,6 +325,8 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) return -EFAULT; /* Returns per-frame error in m.arr. */ m.err = NULL; + if (m.num > SIZE_MAX / sizeof(*m.arr)) + return -EINVAL; if (!access_ok(VERIFY_WRITE, m.arr, m.num * sizeof(*m.arr))) return -EFAULT; break; @@ -332,6 +334,8 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) if (copy_from_user(&m, udata, sizeof(struct privcmd_mmapbatch_v2)))...
2012 Sep 08
3
[patch 1/3] xen/privcmd: check for integer overflow in ioctl
...c b/drivers/xen/privcmd.c index 215a3c0..fdff8f9 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -325,6 +325,8 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) return -EFAULT; /* Returns per-frame error in m.arr. */ m.err = NULL; + if (m.num > SIZE_MAX / sizeof(*m.arr)) + return -EINVAL; if (!access_ok(VERIFY_WRITE, m.arr, m.num * sizeof(*m.arr))) return -EFAULT; break; @@ -332,6 +334,8 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version) if (copy_from_user(&m, udata, sizeof(struct privcmd_mmapbatch_v2)))...
2016 Jul 11
2
[PATCH v3 1/7] lib: string: add functions to case-convert strings
...to store the result. >>> + * @src: The string to convert to uppercase. >>> + */ >>> +static inline void strcpytoupper(char *dst, const char *src) >>> +{ >>> + strlcpytoupper(dst, src, -1); >>> +} >>> + >> >> Why not use SIZE_MAX instead of -1? > > Sure. I'll change all four of them. Thanks. Turns out there's actually a circular dependency here. SIZE_MAX is defined in linux/kernel.h. So, string.h would need to include kernel.h. But kernel.h, by way of several other headers, includes string.h. Attempting to i...
2020 Sep 03
4
[PATCH nbdkit] server/public.c: Uninline nbdkit_strdup_intern to avoid compiler warning.
I'm not sure if this is a GCC bug or a bug in our code, but the attached workaround fixes it for me. Rich.
2016 May 29
2
problems with objects larger than PTRDIFF_MAX
...we support objects of size 65535! Right, the standard doesn't require it. But I guess you don't imply that it's fine for clang to silently miscompile any program that works with objects larger than 65535 bytes. > Their guidance for maximum > object size is stated to be half of SIZE_MAX in C11 K.3.4/4 which is > typically equivalent to PTRDIFF_MAX. Whose guidance? Annex K is kinda alien to the rest of the standard and its future is not clear. See, e.g., http://open-std.org/jtc1/sc22/wg14/www/docs/n1969.htm . > - The expectation that PTRDIFF_MAX is more or less a proxy fo...
2016 Jul 09
2
[PATCH v3 1/7] lib: string: add functions to case-convert strings
...rcpytoupper - Copy string and convert to uppercase. > + * @dst: The buffer to store the result. > + * @src: The string to convert to uppercase. > + */ > +static inline void strcpytoupper(char *dst, const char *src) > +{ > + strlcpytoupper(dst, src, -1); > +} > + Why not use SIZE_MAX instead of -1? > +/** > + * strcpytolower - Copy string and convert to lowercase. > + * @dst: The buffer to store the result. > + * @src: The string to convert to lowercase. > + */ > +static inline void strcpytolower(char *dst, const char *src) > +{ > + strlcpytolower(dst,...
2023 May 10
2
[PATCH] virtio_ring: use u32 for virtio_max_dma_size
...vring_packed_desc. > This means the max segment size supported by virtio is U32_MAX. > > An example of virtio_max_dma_size in virtio_blk.c: > u32 v, max_size; > > max_size = virtio_max_dma_size(vdev); -> implicit convert > err = virtio_cread_feature(vdev, VIRTIO_BLK_F_SIZE_MAX, > struct virtio_blk_config, size_max, &v); > max_size = min(max_size, v); > > There is a risk during implicit convert here, once virtio_max_dma_size > returns 4G, max_size becomes 0. > > Fixes: e6d6dd6c875e ("virtio: Introduce virtio_max...
2018 Mar 20
1
[PATCH] ptr_ring: fix build
.../virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c index 477899c..2d566fb 100644 --- a/tools/virtio/ringtest/ptr_ring.c +++ b/tools/virtio/ringtest/ptr_ring.c @@ -17,6 +17,8 @@ #define likely(x) (__builtin_expect(!!(x), 1)) #define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a)) #define SIZE_MAX (~(size_t)0) +#define KMALLOC_MAX_SIZE SIZE_MAX +#define BUG_ON(x) assert(x) typedef pthread_spinlock_t spinlock_t; @@ -57,6 +59,9 @@ static void kfree(void *p) free(p); } +#define kvmalloc_array kmalloc_array +#define kvfree kfree + static void spin_lock_init(spinlock_t *lock)...
2008 Aug 13
0
MinGW Patch
will surgent wrote: > Hello, I was trying to compile Flac on MinGW/Msys but got an error stating > SIZE_T_MAX is undefined. > To fix this error I edited the file "flac-1.2.1/include/share/alloc.h" and > made the following change: <snip> > #ifndef SIZE_MAX > # ifndef SIZE_T_MAX > # ifdef _MSC_VER > # define SIZE_T_MAX UINT_MAX > # elif defined(__MINGW_H) > # define SIZE_T_MAX UINT_MAX > # else > # error > # endif > # endif > # define SIZE_MAX SIZE_T_MAX > #endif Actually, there might be a better fix for thi...
2019 Jul 22
4
[PATCH 2/2] virtio/virtio_ring: Fix the dma_max_mapping_size call
...virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index c8be1c4f5b55..37c143971211 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -262,7 +262,7 @@ size_t virtio_max_dma_size(struct virtio_device *vdev) > { > size_t max_segment_size = SIZE_MAX; > > - if (vring_use_dma_api(vdev)) > + if (vring_use_dma_api(vdev) && vdev->dev.dma_mask) Hmm, might it make sense to roll that check up into vring_use_dma_api() itself? After all, if the device has no mask then it's likely that other DMA API ops wouldn't really w...