static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)

{

    int flags, in = -1, out = -1;



    flags = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY;

    out = qmp_chardev_open_file_source(file->out, flags, errp);

    if (error_is_set(errp)) {

        return NULL;

    }



    if (file->in) {

        flags = O_RDONLY;

        in = qmp_chardev_open_file_source(file->in, flags, errp);

        if (error_is_set(errp)) {

            qemu_close(out);

            return NULL;

        }

    }



    return qemu_chr_open_fd(in, out);

}

static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp)

{

    int flags, in = -1, out = -1;



    flags = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY;

    out = qmp_chardev_open_file_source(file->out, flags, errp);

    if (error_is_set(errp)) {

        return NULL;

    }



    if (file->in) {

        flags = O_RDONLY;

        in = qmp_chardev_open_file_source(file->in, flags, errp);

        if (error_is_set(errp)) {

            qemu_close(out);

            return NULL;

        }

    }



    return qemu_chr_open_fd(in, out);

}

static CharDriverState *FUNC_0(ChardevFile *file, Error **errp)

{

    int VAR_0, VAR_1 = -1, VAR_2 = -1;



    VAR_0 = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY;

    VAR_2 = qmp_chardev_open_file_source(file->VAR_2, VAR_0, errp);

    if (error_is_set(errp)) {

        return NULL;

    }



    if (file->VAR_1) {

        VAR_0 = O_RDONLY;

        VAR_1 = qmp_chardev_open_file_source(file->VAR_1, VAR_0, errp);

        if (error_is_set(errp)) {

            qemu_close(VAR_2);

            return NULL;

        }

    }



    return qemu_chr_open_fd(VAR_1, VAR_2);

}

static CharDriverState *FUNC_0(ChardevFile *file, Error **errp)
{ int VAR_0, VAR_1 = -1, VAR_2 = -1; VAR_0 = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY; VAR_2 = qmp_chardev_open_file_source(file->VAR_2, VAR_0, errp); if (error_is_set(errp)) { return NULL; } if (file->VAR_1) { VAR_0 = O_RDONLY; VAR_1 = qmp_chardev_open_file_source(file->VAR_1, VAR_0, errp); if (error_is_set(errp)) { qemu_close(VAR_2); return NULL; } } return qemu_chr_open_fd(VAR_1, VAR_2); }