aboutsummaryrefslogtreecommitdiff
path: root/qemu-io-cmds.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-05-12 09:10:56 -0600
committerKevin Wolf <kwolf@redhat.com>2015-05-22 17:08:01 +0200
commitb062ad86dcd33ab39be5060b0655d8e13834b167 (patch)
tree60f38226e95d0855988d954705a150948eb6750b /qemu-io-cmds.c
parentd1b4efe5c4088fd2289e39b95bbdf73b3dcb7432 (diff)
qemu-io: Use getopt() correctly
POSIX says getopt() returns -1 on completion. While Linux happens to define EOF as -1, this definition is not required by POSIX, and there may be platforms where checking for EOF instead of -1 would lead to an infinite loop. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-io-cmds.c')
-rw-r--r--qemu-io-cmds.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 1afcfc01a5..52dc6111bf 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -646,7 +646,7 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
int total = 0;
int pattern = 0, pattern_offset = 0, pattern_count = 0;
- while ((c = getopt(argc, argv, "bCl:pP:qs:v")) != EOF) {
+ while ((c = getopt(argc, argv, "bCl:pP:qs:v")) != -1) {
switch (c) {
case 'b':
bflag = 1;
@@ -830,7 +830,7 @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
int pattern = 0;
int Pflag = 0;
- while ((c = getopt(argc, argv, "CP:qv")) != EOF) {
+ while ((c = getopt(argc, argv, "CP:qv")) != -1) {
switch (c) {
case 'C':
Cflag = 1;
@@ -961,7 +961,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
int total = 0;
int pattern = 0xcd;
- while ((c = getopt(argc, argv, "bcCpP:qz")) != EOF) {
+ while ((c = getopt(argc, argv, "bcCpP:qz")) != -1) {
switch (c) {
case 'b':
bflag = 1;
@@ -1116,7 +1116,7 @@ static int writev_f(BlockBackend *blk, int argc, char **argv)
int pattern = 0xcd;
QEMUIOVector qiov;
- while ((c = getopt(argc, argv, "CqP:")) != EOF) {
+ while ((c = getopt(argc, argv, "CqP:")) != -1) {
switch (c) {
case 'C':
Cflag = 1;
@@ -1228,7 +1228,7 @@ static int multiwrite_f(BlockBackend *blk, int argc, char **argv)
int i;
BlockRequest *reqs;
- while ((c = getopt(argc, argv, "CqP:")) != EOF) {
+ while ((c = getopt(argc, argv, "CqP:")) != -1) {
switch (c) {
case 'C':
Cflag = 1;
@@ -1463,7 +1463,7 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv)
struct aio_ctx *ctx = g_new0(struct aio_ctx, 1);
ctx->blk = blk;
- while ((c = getopt(argc, argv, "CP:qv")) != EOF) {
+ while ((c = getopt(argc, argv, "CP:qv")) != -1) {
switch (c) {
case 'C':
ctx->Cflag = 1;
@@ -1562,7 +1562,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
struct aio_ctx *ctx = g_new0(struct aio_ctx, 1);
ctx->blk = blk;
- while ((c = getopt(argc, argv, "CqP:")) != EOF) {
+ while ((c = getopt(argc, argv, "CqP:")) != -1) {
switch (c) {
case 'C':
ctx->Cflag = 1;
@@ -1779,7 +1779,7 @@ static int discard_f(BlockBackend *blk, int argc, char **argv)
int64_t offset;
int count;
- while ((c = getopt(argc, argv, "Cq")) != EOF) {
+ while ((c = getopt(argc, argv, "Cq")) != -1) {
switch (c) {
case 'C':
Cflag = 1;