Commit f0ccc00b authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Markus Armbruster
Browse files

qmp: constify QmpCommand and list



Since 0b69f6f7 "qapi: remove
qmp_unregister_command()", the command list can be declared const.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: default avatarDamien Hedde <damien.hedde@greensocs.com>
Message-Id: <20200316171824.2319695-1-marcandre.lureau@redhat.com>
[Rebased]
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent df4097ae
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -39,7 +39,8 @@ typedef QTAILQ_HEAD(QmpCommandList, QmpCommand) QmpCommandList;

void qmp_register_command(QmpCommandList *cmds, const char *name,
                          QmpCommandFunc *fn, QmpCommandOptions options);
QmpCommand *qmp_find_command(QmpCommandList *cmds, const char *name);
const QmpCommand *qmp_find_command(const QmpCommandList *cmds,
                                   const char *name);
void qmp_disable_command(QmpCommandList *cmds, const char *name);
void qmp_enable_command(QmpCommandList *cmds, const char *name);

@@ -47,13 +48,13 @@ bool qmp_command_is_enabled(const QmpCommand *cmd);
const char *qmp_command_name(const QmpCommand *cmd);
bool qmp_has_success_response(const QmpCommand *cmd);
QDict *qmp_error_response(Error *err);
QDict *qmp_dispatch(QmpCommandList *cmds, QObject *request,
QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
                    bool allow_oob);
bool qmp_is_oob(const QDict *dict);

typedef void (*qmp_cmd_callback_fn)(QmpCommand *cmd, void *opaque);
typedef void (*qmp_cmd_callback_fn)(const QmpCommand *cmd, void *opaque);

void qmp_for_each_command(QmpCommandList *cmds, qmp_cmd_callback_fn fn,
void qmp_for_each_command(const QmpCommandList *cmds, qmp_cmd_callback_fn fn,
                          void *opaque);

#endif
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ typedef struct {
     * qmp_capabilities succeeds, we go into command mode, and
     * @command becomes &qmp_commands.
     */
    QmpCommandList *commands;
    const QmpCommandList *commands;
    bool capab_offered[QMP_CAPABILITY__MAX]; /* capabilities offered */
    bool capab[QMP_CAPABILITY__MAX];         /* offered and accepted */
    /*
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ VersionInfo *qmp_query_version(Error **errp)
    return info;
}

static void query_commands_cb(QmpCommand *cmd, void *opaque)
static void query_commands_cb(const QmpCommand *cmd, void *opaque)
{
    CommandInfoList *info, **list = opaque;

+2 −2
Original line number Diff line number Diff line
@@ -88,14 +88,14 @@ bool qmp_is_oob(const QDict *dict)
        && !qdict_haskey(dict, "execute");
}

QDict *qmp_dispatch(QmpCommandList *cmds, QObject *request,
QDict *qmp_dispatch(const QmpCommandList *cmds, QObject *request,
                    bool allow_oob)
{
    Error *err = NULL;
    bool oob;
    const char *command;
    QDict *args;
    QmpCommand *cmd;
    const QmpCommand *cmd;
    QDict *dict;
    QObject *id;
    QObject *ret = NULL;
+3 −3
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ void qmp_register_command(QmpCommandList *cmds, const char *name,
    QTAILQ_INSERT_TAIL(cmds, cmd, node);
}

QmpCommand *qmp_find_command(QmpCommandList *cmds, const char *name)
const QmpCommand *qmp_find_command(const QmpCommandList *cmds, const char *name)
{
    QmpCommand *cmd;

@@ -77,10 +77,10 @@ bool qmp_has_success_response(const QmpCommand *cmd)
    return !(cmd->options & QCO_NO_SUCCESS_RESP);
}

void qmp_for_each_command(QmpCommandList *cmds, qmp_cmd_callback_fn fn,
void qmp_for_each_command(const QmpCommandList *cmds, qmp_cmd_callback_fn fn,
                          void *opaque)
{
    QmpCommand *cmd;
    const QmpCommand *cmd;

    QTAILQ_FOREACH(cmd, cmds, node) {
        fn(cmd, opaque);
Loading