Commit bc1256f7 authored by Michael R. Hines's avatar Michael R. Hines Committed by Juan Quintela
Browse files

rdma: introduce qemu_file_mode_is_not_valid()



QEMUFileRDMA also has read and write modes. This function is now
shared to reduce code duplication.
Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarChegu Vinod <chegu_vinod@hp.com>
Tested-by: default avatarChegu Vinod <chegu_vinod@hp.com>
Tested-by: default avatarMichael R. Hines <mrhines@us.ibm.com>
Signed-off-by: default avatarMichael R. Hines <mrhines@us.ibm.com>
Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
parent 7e114f8c
......@@ -80,6 +80,7 @@ void qemu_put_byte(QEMUFile *f, int v);
* The buffer should be available till it is sent asynchronously.
*/
void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size);
bool qemu_file_mode_is_not_valid(const char *mode);
static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
{
......
......@@ -449,14 +449,23 @@ static const QEMUFileOps socket_write_ops = {
.close = socket_close
};
QEMUFile *qemu_fopen_socket(int fd, const char *mode)
bool qemu_file_mode_is_not_valid(const char *mode)
{
QEMUFileSocket *s;
if (mode == NULL ||
(mode[0] != 'r' && mode[0] != 'w') ||
mode[1] != 'b' || mode[2] != 0) {
fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
return true;
}
return false;
}
QEMUFile *qemu_fopen_socket(int fd, const char *mode)
{
QEMUFileSocket *s;
if (qemu_file_mode_is_not_valid(mode)) {
return NULL;
}
......@@ -475,10 +484,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
{
QEMUFileStdio *s;
if (mode == NULL ||
(mode[0] != 'r' && mode[0] != 'w') ||
mode[1] != 'b' || mode[2] != 0) {
fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
if (qemu_file_mode_is_not_valid(mode)) {
return NULL;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment