Skip to content

Commit

Permalink
chardev: src buffer const for write functions
Browse files Browse the repository at this point in the history
Make source buffers const for char be write functions.
This allows using buffers returned by fifo as buf parameter and source buffer
should not be changed by write functions anyway.

Signed-off-by: Arwed Meyer <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
ByteMaster1337 authored and elmarco committed Sep 29, 2022
1 parent a39fe10 commit 8f9abdf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chardev/char.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int qemu_chr_be_can_write(Chardev *s)
return be->chr_can_read(be->opaque);
}

void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len)
void qemu_chr_be_write_impl(Chardev *s, const uint8_t *buf, int len)
{
CharBackend *be = s->be;

Expand All @@ -202,7 +202,7 @@ void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len)
}
}

void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len)
void qemu_chr_be_write(Chardev *s, const uint8_t *buf, int len)
{
if (qemu_chr_replay(s)) {
if (replay_mode == REPLAY_MODE_PLAY) {
Expand Down
4 changes: 2 additions & 2 deletions include/chardev/char.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ int qemu_chr_be_can_write(Chardev *s);
* the caller should call @qemu_chr_be_can_write to determine how much data
* the front end can currently accept.
*/
void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len);
void qemu_chr_be_write(Chardev *s, const uint8_t *buf, int len);

/**
* qemu_chr_be_write_impl:
Expand All @@ -195,7 +195,7 @@ void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len);
*
* Implementation of back end writing. Used by replay module.
*/
void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len);
void qemu_chr_be_write_impl(Chardev *s, const uint8_t *buf, int len);

/**
* qemu_chr_be_update_read_handlers:
Expand Down
2 changes: 1 addition & 1 deletion include/sysemu/replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ uint64_t blkreplay_next_id(void);
/*! Registers char driver to save it's events */
void replay_register_char_driver(struct Chardev *chr);
/*! Saves write to char device event to the log */
void replay_chr_be_write(struct Chardev *s, uint8_t *buf, int len);
void replay_chr_be_write(struct Chardev *s, const uint8_t *buf, int len);
/*! Writes char write return value to the replay log. */
void replay_char_write_event_save(int res, int offset);
/*! Reads char write return value from the replay log. */
Expand Down
2 changes: 1 addition & 1 deletion replay/replay-char.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void replay_register_char_driver(Chardev *chr)
char_drivers[drivers_count++] = chr;
}

void replay_chr_be_write(Chardev *s, uint8_t *buf, int len)
void replay_chr_be_write(Chardev *s, const uint8_t *buf, int len)
{
CharEvent *event = g_new0(CharEvent, 1);

Expand Down
2 changes: 1 addition & 1 deletion stubs/replay-tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void replay_register_char_driver(struct Chardev *chr)
{
}

void replay_chr_be_write(struct Chardev *s, uint8_t *buf, int len)
void replay_chr_be_write(struct Chardev *s, const uint8_t *buf, int len)
{
abort();
}
Expand Down

0 comments on commit 8f9abdf

Please sign in to comment.