static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)

{

    const char *fdname = qdict_get_str(qdict, "fdname");

    mon_fd_t *monfd;

    int fd;



    fd = qemu_chr_get_msgfd(mon->chr);

    if (fd == -1) {

        qerror_report(QERR_FD_NOT_SUPPLIED);

        return -1;

    }



    if (qemu_isdigit(fdname[0])) {

        qerror_report(QERR_INVALID_PARAMETER_VALUE, "fdname",

                      "a name not starting with a digit");

        return -1;

    }



    fd = dup(fd);

    if (fd == -1) {

        if (errno == EMFILE)

            qerror_report(QERR_TOO_MANY_FILES);

        else

            qerror_report(QERR_UNDEFINED_ERROR);

        return -1;

    }



    QLIST_FOREACH(monfd, &mon->fds, next) {

        if (strcmp(monfd->name, fdname) != 0) {

            continue;

        }



        close(monfd->fd);

        monfd->fd = fd;

        return 0;

    }



    monfd = qemu_mallocz(sizeof(mon_fd_t));

    monfd->name = qemu_strdup(fdname);

    monfd->fd = fd;



    QLIST_INSERT_HEAD(&mon->fds, monfd, next);

    return 0;

}

static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)

{

    const char *fdname = qdict_get_str(qdict, "fdname");

    mon_fd_t *monfd;

    int fd;



    fd = qemu_chr_get_msgfd(mon->chr);

    if (fd == -1) {

        qerror_report(QERR_FD_NOT_SUPPLIED);

        return -1;

    }



    if (qemu_isdigit(fdname[0])) {

        qerror_report(QERR_INVALID_PARAMETER_VALUE, "fdname",

                      "a name not starting with a digit");

        return -1;

    }



    fd = dup(fd);

    if (fd == -1) {

        if (errno == EMFILE)

            qerror_report(QERR_TOO_MANY_FILES);

        else

            qerror_report(QERR_UNDEFINED_ERROR);

        return -1;

    }



    QLIST_FOREACH(monfd, &mon->fds, next) {

        if (strcmp(monfd->name, fdname) != 0) {

            continue;

        }



        close(monfd->fd);

        monfd->fd = fd;

        return 0;

    }



    monfd = qemu_mallocz(sizeof(mon_fd_t));

    monfd->name = qemu_strdup(fdname);

    monfd->fd = fd;



    QLIST_INSERT_HEAD(&mon->fds, monfd, next);

    return 0;

}

    fd = dup(fd);     if (fd == -1) {         if (errno == EMFILE)             qerror_report(QERR_TOO_MANY_FILES);             qerror_report(QERR_UNDEFINED_ERROR);         return -1;
static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)

{

    const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3");

    mon_fd_t *monfd;

    int VAR_4;



    VAR_4 = qemu_chr_get_msgfd(VAR_0->chr);

    if (VAR_4 == -1) {

        qerror_report(QERR_FD_NOT_SUPPLIED);

        return -1;

    }



    if (qemu_isdigit(VAR_3[0])) {

        qerror_report(QERR_INVALID_PARAMETER_VALUE, "VAR_3",

                      "a name not starting with a digit");

        return -1;

    }



    VAR_4 = dup(VAR_4);

    if (VAR_4 == -1) {

        if (errno == EMFILE)

            qerror_report(QERR_TOO_MANY_FILES);

        else

            qerror_report(QERR_UNDEFINED_ERROR);

        return -1;

    }



    QLIST_FOREACH(monfd, &VAR_0->fds, next) {

        if (strcmp(monfd->name, VAR_3) != 0) {

            continue;

        }



        close(monfd->VAR_4);

        monfd->VAR_4 = VAR_4;

        return 0;

    }



    monfd = qemu_mallocz(sizeof(mon_fd_t));

    monfd->name = qemu_strdup(VAR_3);

    monfd->VAR_4 = VAR_4;



    QLIST_INSERT_HEAD(&VAR_0->fds, monfd, next);

    return 0;

}

static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)
{ const char *VAR_3 = qdict_get_str(VAR_1, "VAR_3"); mon_fd_t *monfd; int VAR_4; VAR_4 = qemu_chr_get_msgfd(VAR_0->chr); if (VAR_4 == -1) { qerror_report(QERR_FD_NOT_SUPPLIED); return -1; } if (qemu_isdigit(VAR_3[0])) { qerror_report(QERR_INVALID_PARAMETER_VALUE, "VAR_3",
"a name not starting with a digit"); return -1; } VAR_4 = dup(VAR_4); if (VAR_4 == -1) { if (errno == EMFILE)
qerror_report(QERR_TOO_MANY_FILES); else
qerror_report(QERR_UNDEFINED_ERROR); return -1; } QLIST_FOREACH(monfd, &VAR_0->fds, next) { if (strcmp(monfd->name, VAR_3) != 0) { continue; } close(monfd->VAR_4); monfd->VAR_4 = VAR_4; return 0; } monfd = qemu_mallocz(sizeof(mon_fd_t)); monfd->name = qemu_strdup(VAR_3); monfd->VAR_4 = VAR_4; QLIST_INSERT_HEAD(&VAR_0->fds, monfd, next); return 0; }