Skip to content

Commit

Permalink
Fix OpenBSD build of qemu-io
Browse files Browse the repository at this point in the history
GCC 3.3.5 generates warnings for static forward declarations of data, so
rearrange code to use static forward declarations of functions instead.

Use <getopt.h> for optind instead of local definition.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
  • Loading branch information
blueswirl committed Nov 21, 2009
1 parent 3a3fb96 commit 22a2bdc
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 89 deletions.
3 changes: 1 addition & 2 deletions cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
#include <ctype.h>
#include <errno.h>
#include <sys/time.h>
#include <getopt.h>

#include "cmd.h"

#define _(x) x /* not gettext support yet */

extern int optind;

/* from libxcmd/command.c */

cmdinfo_t *cmdtab;
Expand Down
173 changes: 86 additions & 87 deletions qemu-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ static int do_aio_writev(QEMUIOVector *qiov, int64_t offset, int *total)
}


static const cmdinfo_t read_cmd;

static void
read_help(void)
{
Expand All @@ -291,6 +289,19 @@ read_help(void)
"\n");
}

static int read_f(int argc, char **argv);

static const cmdinfo_t read_cmd = {
.name = "read",
.altname = "r",
.cfunc = read_f,
.argmin = 2,
.argmax = -1,
.args = "[-abCpqv] [-P pattern [-s off] [-l len]] off len",
.oneline = "reads a number of bytes at a specified offset",
.help = read_help,
};

static int
read_f(int argc, char **argv)
{
Expand Down Expand Up @@ -439,19 +450,6 @@ read_f(int argc, char **argv)
return 0;
}

static const cmdinfo_t read_cmd = {
.name = "read",
.altname = "r",
.cfunc = read_f,
.argmin = 2,
.argmax = -1,
.args = "[-abCpqv] [-P pattern [-s off] [-l len]] off len",
.oneline = "reads a number of bytes at a specified offset",
.help = read_help,
};

static const cmdinfo_t readv_cmd;

static void
readv_help(void)
{
Expand All @@ -472,6 +470,18 @@ readv_help(void)
"\n");
}

static int readv_f(int argc, char **argv);

static const cmdinfo_t readv_cmd = {
.name = "readv",
.cfunc = readv_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cqv] [-P pattern ] off len [len..]",
.oneline = "reads a number of bytes at a specified offset",
.help = readv_help,
};

static int
readv_f(int argc, char **argv)
{
Expand Down Expand Up @@ -563,18 +573,6 @@ readv_f(int argc, char **argv)
return 0;
}

static const cmdinfo_t readv_cmd = {
.name = "readv",
.cfunc = readv_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cqv] [-P pattern ] off len [len..]",
.oneline = "reads a number of bytes at a specified offset",
.help = readv_help,
};

static const cmdinfo_t write_cmd;

static void
write_help(void)
{
Expand All @@ -595,6 +593,19 @@ write_help(void)
"\n");
}

static int write_f(int argc, char **argv);

static const cmdinfo_t write_cmd = {
.name = "write",
.altname = "w",
.cfunc = write_f,
.argmin = 2,
.argmax = -1,
.args = "[-abCpq] [-P pattern ] off len",
.oneline = "writes a number of bytes at a specified offset",
.help = write_help,
};

static int
write_f(int argc, char **argv)
{
Expand Down Expand Up @@ -696,19 +707,6 @@ write_f(int argc, char **argv)
return 0;
}

static const cmdinfo_t write_cmd = {
.name = "write",
.altname = "w",
.cfunc = write_f,
.argmin = 2,
.argmax = -1,
.args = "[-abCpq] [-P pattern ] off len",
.oneline = "writes a number of bytes at a specified offset",
.help = write_help,
};

static const cmdinfo_t writev_cmd;

static void
writev_help(void)
{
Expand All @@ -727,6 +725,18 @@ writev_help(void)
"\n");
}

static int writev_f(int argc, char **argv);

static const cmdinfo_t writev_cmd = {
.name = "writev",
.cfunc = writev_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cq] [-P pattern ] off len [len..]",
.oneline = "writes a number of bytes at a specified offset",
.help = writev_help,
};

static int
writev_f(int argc, char **argv)
{
Expand Down Expand Up @@ -797,16 +807,6 @@ writev_f(int argc, char **argv)
return 0;
}

static const cmdinfo_t writev_cmd = {
.name = "writev",
.cfunc = writev_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cq] [-P pattern ] off len [len..]",
.oneline = "writes a number of bytes at a specified offset",
.help = writev_help,
};

struct aio_ctx {
QEMUIOVector qiov;
int64_t offset;
Expand Down Expand Up @@ -846,8 +846,6 @@ aio_write_done(void *opaque, int ret)
free(ctx);
}

static const cmdinfo_t aio_read_cmd;

static void
aio_read_done(void *opaque, int ret)
{
Expand Down Expand Up @@ -911,6 +909,18 @@ aio_read_help(void)
"\n");
}

static int aio_read_f(int argc, char **argv);

static const cmdinfo_t aio_read_cmd = {
.name = "aio_read",
.cfunc = aio_read_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cqv] [-P pattern ] off len [len..]",
.oneline = "asynchronously reads a number of bytes",
.help = aio_read_help,
};

static int
aio_read_f(int argc, char **argv)
{
Expand Down Expand Up @@ -976,18 +986,6 @@ aio_read_f(int argc, char **argv)
return 0;
}

static const cmdinfo_t aio_read_cmd = {
.name = "aio_read",
.cfunc = aio_read_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cqv] [-P pattern ] off len [len..]",
.oneline = "asynchronously reads a number of bytes",
.help = aio_read_help,
};

static const cmdinfo_t aio_write_cmd;

static void
aio_write_help(void)
{
Expand All @@ -1009,6 +1007,17 @@ aio_write_help(void)
"\n");
}

static int aio_write_f(int argc, char **argv);

static const cmdinfo_t aio_write_cmd = {
.name = "aio_write",
.cfunc = aio_write_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cq] [-P pattern ] off len [len..]",
.oneline = "asynchronously writes a number of bytes",
.help = aio_write_help,
};

static int
aio_write_f(int argc, char **argv)
Expand Down Expand Up @@ -1072,16 +1081,6 @@ aio_write_f(int argc, char **argv)
return 0;
}

static const cmdinfo_t aio_write_cmd = {
.name = "aio_write",
.cfunc = aio_write_f,
.argmin = 2,
.argmax = -1,
.args = "[-Cq] [-P pattern ] off len [len..]",
.oneline = "asynchronously writes a number of bytes",
.help = aio_write_help,
};

static int
aio_flush_f(int argc, char **argv)
{
Expand Down Expand Up @@ -1312,7 +1311,19 @@ open_help(void)
"\n");
}

static const cmdinfo_t open_cmd;
static int open_f(int argc, char **argv);

static const cmdinfo_t open_cmd = {
.name = "open",
.altname = "o",
.cfunc = open_f,
.argmin = 1,
.argmax = -1,
.flags = CMD_NOFILE_OK,
.args = "[-Crsn] [path]",
.oneline = "open the file specified by path",
.help = open_help,
};

static int
open_f(int argc, char **argv)
Expand Down Expand Up @@ -1355,18 +1366,6 @@ open_f(int argc, char **argv)
return openfile(argv[optind], flags, growable);
}

static const cmdinfo_t open_cmd = {
.name = "open",
.altname = "o",
.cfunc = open_f,
.argmin = 1,
.argmax = -1,
.flags = CMD_NOFILE_OK,
.args = "[-Crsn] [path]",
.oneline = "open the file specified by path",
.help = open_help,
};

static int
init_args_command(
int index)
Expand Down

0 comments on commit 22a2bdc

Please sign in to comment.