From 48bf317fed5cf8f0722a7464b4b89b467d9a5eda Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 21 Oct 2003 10:00:29 +0000 Subject: [PATCH] Fix lfs_getstripe not to declare variables after code. This does not work with GCC < 3.0, and most Lustre users use GCC 2.9x. b=1944 --- lustre/utils/lfs.c | 58 ++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 69af690..f6a169d 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -34,9 +34,9 @@ #include "parser.h" -extern int op_create_file(char *name, long stripe_size, int stripe_offset, +extern int op_create_file(char *name, long stripe_size, int stripe_offset, int stripe_count); -extern int op_find(char *path, struct obd_uuid *obduuid, int recursive, +extern int op_find(char *path, struct obd_uuid *obduuid, int recursive, int verbose, int quiet); /* all functions */ @@ -66,33 +66,33 @@ command_t cmdlist[] = { /* functions */ static int lfs_setstripe(int argc, char **argv) -{ +{ int result; long st_size; int st_offset, st_count; char *end; - - if (argc != 5) + + if (argc != 5) return CMD_HELP; // get the stripe size st_size = strtoul(argv[2], &end, 0); if (*end != '\0') { - fprintf(stderr, "error: %s: bad stripe size '%s'\n", + fprintf(stderr, "error: %s: bad stripe size '%s'\n", argv[0], argv[2]); return CMD_HELP; } // get the stripe offset st_offset = strtoul(argv[3], &end, 0); if (*end != '\0') { - fprintf(stderr, "error: %s: bad stripe offset '%s'\n", + fprintf(stderr, "error: %s: bad stripe offset '%s'\n", argv[0], argv[3]); return CMD_HELP; } - // get the stripe count + // get the stripe count st_count = strtoul(argv[4], &end, 0); if (*end != '\0') { - fprintf(stderr, "error: %s: bad stripe count '%s'\n", + fprintf(stderr, "error: %s: bad stripe count '%s'\n", argv[0], argv[4]); return CMD_HELP; } @@ -117,16 +117,17 @@ static int lfs_find(int argc, char **argv) char short_opts[] = "ho:qrv"; int quiet, verbose, recursive, c, rc; struct obd_uuid *obduuid = NULL; - + optind = 0; quiet = verbose = recursive = 0; - while ((c = getopt_long(argc, argv, short_opts, + while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { switch (c) { case 'o': if (obduuid) { - fprintf(stderr, "error: %s: only one obduuid allowed", - argv[0]); + fprintf(stderr, + "error: %s: only one obduuid allowed", + argv[0]); return CMD_HELP; } obduuid = (struct obd_uuid *)optarg; @@ -146,19 +147,19 @@ static int lfs_find(int argc, char **argv) return CMD_HELP; break; default: - fprintf(stderr, "error: %s: option '%s' unrecognized\n", - argv[0], argv[optind - 1]); + fprintf(stderr, "error: %s: option '%s' unrecognized\n", + argv[0], argv[optind - 1]); return CMD_HELP; break; } } - if (optind >= argc) + if (optind >= argc) return CMD_HELP; do { rc = op_find(argv[optind], obduuid, recursive, verbose, quiet); - } while (++optind < argc && !rc); + } while (++optind < argc && !rc); if (rc) fprintf(stderr, "error: %s: find failed\n", argv[0]); @@ -167,25 +168,22 @@ static int lfs_find(int argc, char **argv) static int lfs_getstripe(int argc, char **argv) { - + struct obd_uuid *obduuid = NULL; + int rc; + if (argc != 2) return CMD_HELP; - - int quiet, verbose, recursive, rc; - struct obd_uuid *obduuid = NULL; - - + optind = 1; - quiet = verbose = recursive = 0; - - + do { - rc = op_find(argv[optind], obduuid, recursive, verbose, quiet); + rc = op_find(argv[optind], obduuid, 0, 0, 0); } while (++optind < argc && !rc); - - + if (rc) - fprintf(stderr, "error: %s: getstripe failed\n", argv[0]); + fprintf(stderr, "error: %s: getstripe failed for %s\n", + argv[0], argv[1]); + return rc; } -- 1.8.3.1