search for: new_bitmap

Displaying 11 results from an estimated 11 matches for "new_bitmap".

2019 Sep 13
1
[PATCH nbdkit] common/bitmap: Don't fail on realloc (ptr, 0)
...1 insertion(+), 1 deletion(-) diff --git a/common/bitmap/bitmap.c b/common/bitmap/bitmap.c index caac916..6bf04dc 100644 --- a/common/bitmap/bitmap.c +++ b/common/bitmap/bitmap.c @@ -60,7 +60,7 @@ bitmap_resize (struct bitmap *bm, uint64_t new_size) new_bm_size = (size_t) new_bm_size_u64; new_bitmap = realloc (bm->bitmap, new_bm_size); - if (new_bitmap == NULL) { + if (new_bm_size && new_bitmap == NULL) { nbdkit_error ("realloc: %m"); return -1; } -- 2.23.0
2019 Sep 15
0
[PATCH nbdkit v2] common/bitmap: Don't fail on realloc (ptr, 0)
...ions(+), 4 deletions(-) diff --git a/common/bitmap/bitmap.c b/common/bitmap/bitmap.c index caac916..2cc625c 100644 --- a/common/bitmap/bitmap.c +++ b/common/bitmap/bitmap.c @@ -59,10 +59,16 @@ bitmap_resize (struct bitmap *bm, uint64_t new_size) } new_bm_size = (size_t) new_bm_size_u64; - new_bitmap = realloc (bm->bitmap, new_bm_size); - if (new_bitmap == NULL) { - nbdkit_error ("realloc: %m"); - return -1; + if (new_bm_size > 0) { + new_bitmap = realloc (bm->bitmap, new_bm_size); + if (new_bitmap == NULL) { + nbdkit_error ("realloc: %m"); +...
2019 Sep 15
2
[PATCH nbdkit v2] common/bitmap: Don't fail on realloc (ptr, 0)
v1 was here: https://www.redhat.com/archives/libguestfs/2019-September/msg00100.html In v2 I've changed the patch so it avoids calling realloc at all in this case. The patch is a bit longer this way. But I don't see any other alternative if we are to avoid having a "realloc wrapper" of some kind that we use everywhere, which I guess we should avoid because it makes plugins
2023 Jun 25
0
[PATCH 08/26] virtio-mem: use array_size
...array = vzalloc(array_size(new_pages, PAGE_SIZE)); > if (!new_array) > return -ENOMEM; > > @@ -588,7 +588,7 @@ static int virtio_mem_sbm_sb_states_prepare_next_mb(struct virtio_mem *vm) > if (vm->sbm.sb_states && old_pages == new_pages) > return 0; > > - new_bitmap = vzalloc(new_pages * PAGE_SIZE); > + new_bitmap = vzalloc(array_size(new_pages, PAGE_SIZE)); > if (!new_bitmap) > return -ENOMEM; > >
2018 Dec 01
2
[PATCH nbdkit] common: Move shared bitmap code to a common library.
I have some patches I'm working on to fix the cache filter. However this is a prelude. It should be simply pure refactoring. All tests pass still. Rich.
2018 Dec 02
2
[PATCH nbdkit v2] common: Move shared bitmap code to a common library.
This is exactly the same as v1: https://www.redhat.com/archives/libguestfs/2018-December/msg00004.html except that it now frees the bitmap on unload (which the old code did not - there was always a memory leak). Rich.
2018 Dec 01
0
[PATCH nbdkit] common: Move shared bitmap code to a common library.
...config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include <nbdkit-plugin.h> + +#include "bitmap.h" +#include "rounding.h" + +int +bitmap_resize (struct bitmap *bm, uint64_t new_size) +{ + uint8_t *new_bitmap; + const size_t old_bm_size = bm->size; + uint64_t new_bm_size_u64; + size_t new_bm_size; + + new_bm_size_u64 = DIV_ROUND_UP (new_size, bm->blksize * 8 / bm->bpb); + if (new_bm_size_u64 > SIZE_MAX) { + nbdkit_error ("bitmap too large for this architecture"); + retur...
2018 Dec 02
0
[PATCH nbdkit v2] common: Move shared bitmap code to a common library.
...config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include <nbdkit-plugin.h> + +#include "bitmap.h" +#include "rounding.h" + +int +bitmap_resize (struct bitmap *bm, uint64_t new_size) +{ + uint8_t *new_bitmap; + const size_t old_bm_size = bm->size; + uint64_t new_bm_size_u64; + size_t new_bm_size; + + new_bm_size_u64 = DIV_ROUND_UP (new_size, bm->blksize * 8 / bm->bpb); + if (new_bm_size_u64 > SIZE_MAX) { + nbdkit_error ("bitmap too large for this architecture"); + retur...
2018 Dec 03
0
[PATCH nbdkit v3] common: Move shared bitmap code to a common library.
...config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include <nbdkit-plugin.h> + +#include "bitmap.h" +#include "rounding.h" + +int +bitmap_resize (struct bitmap *bm, uint64_t new_size) +{ + uint8_t *new_bitmap; + const size_t old_bm_size = bm->size; + uint64_t new_bm_size_u64; + size_t new_bm_size; + + new_bm_size_u64 = DIV_ROUND_UP (new_size, + bm->blksize * UINT64_C(8) / bm->bpb); + if (new_bm_size_u64 > SIZE_MAX) { + nbdkit_error ("bitmap too l...
2018 Dec 03
3
[PATCH nbdkit v3] common: Move shared bitmap code to a common library.
v2: https://www.redhat.com/archives/libguestfs/2018-December/msg00039.html v2 -> v3: - Fix all the issues raised in Eric's review. - Precompute some numbers to make the calculations easier. - Calculations now use bitshifts and masks in preference to division and modulo. - Clear existing bits before setting (which fixes a bug in the cache filter). Rich.
2018 Dec 03
1
Re: [PATCH nbdkit v2] common: Move shared bitmap code to a common library.
...low logically (what gets built, what interfaces does it need, and how is it implemented). 'git config diff.orderFile /path/to/file'; see qemu's scripts/git.orderfile for an example. > + > +int > +bitmap_resize (struct bitmap *bm, uint64_t new_size) > +{ > + uint8_t *new_bitmap; > + const size_t old_bm_size = bm->size; > + uint64_t new_bm_size_u64; > + size_t new_bm_size; > + > + new_bm_size_u64 = DIV_ROUND_UP (new_size, bm->blksize * 8 / bm->bpb); Can the computation of bm->blksize * 8 overflow? (blksize is 32-bit unsigned; did initializa...