static int dump_cleanup(DumpState *s)
> @@ -754,6 +757,22 @@ static int write_buffer(int fd, bool flag_flatten,
off_t offset, void *buf,
> return 0;
> }
>
> +static int buf_write_note(void *buf, size_t size, void *opaque)
> +{
"const void *buf" would have been more "elegant".
> + DumpState *s = opaque;
> +
> + /* note_buf is not enough */
> + if (s->note_buf_offset + size> s->note_size) {
> + return -1;
> + }
> +
> + memcpy(s->note_buf + s->note_buf_offset, buf, size);
Giving type "uint8_t" to "*note_buf" would have been preferable.
Addition to a pointer-to-void is a constraint violation in standard C
("... operand shall be a pointer to an object type ..."), ie. it's a gcc
extension here, but I guess we can live with it.
Using s->note_size as limit seems correct.