From: DAN LI <li.dan@cn.fujitsu.com>
To: LTP list <ltp-list@lists.sourceforge.net>
Subject: [LTP] [PATCH] inotify/inotify03.c: cleanup a parameter-passing error
Date: Tue, 16 Jul 2013 11:09:10 +0800 [thread overview]
Message-ID: <51E4B956.9020708@cn.fujitsu.com> (raw)
1. Revise code to follow ltp-code-style
2. Fix a bad parameter-passing which causes mount(2) "EINVAL"
Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
testcases/kernel/syscalls/inotify/inotify03.c | 48 +++++++++++----------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c
index 12545b8..f17004f 100644
--- a/testcases/kernel/syscalls/inotify/inotify03.c
+++ b/testcases/kernel/syscalls/inotify/inotify03.c
@@ -59,7 +59,7 @@ int TST_TOTAL = 3;
#define EVENT_MAX 1024
/* size of the event structure, not counting name */
-#define EVENT_SIZE (sizeof (struct inotify_event))
+#define EVENT_SIZE (sizeof(struct inotify_event))
/* reasonable guess as to size of 1024 events */
#define EVENT_BUF_LEN (EVENT_MAX * (EVENT_SIZE + 16))
@@ -77,37 +77,35 @@ int event_set[EVENT_MAX];
char event_buf[EVENT_BUF_LEN];
-#define DIR_MODE S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP
+#define DIR_MODE (S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP)
-static char *Fstype;
static char mntpoint[20];
-static int mount_flag = 0;
+static int mount_flag;
static char *fstype = "ext2";
static char *device;
-static int Tflag = 0;
-static int Dflag = 0;
+static int dflag;
static option_t options[] = {
- {"T:", &Tflag, &fstype},
- {"D:", &Dflag, &device},
+ {"T:", NULL, &fstype},
+ {"D:", &dflag, &device},
{NULL, NULL, NULL}
};
-int main(int ac, char **av)
+int main(int argc, char *argv[])
{
char *msg;
int ret;
int len, i, test_num;
- if ((msg = parse_opts(ac, av, options, &help)) != NULL)
+ msg = parse_opts(argc, argv, options, &help);
+ if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
/* Check for mandatory option of the testcase */
- if (!Dflag) {
+ if (!dflag)
tst_brkm(TBROK, NULL, "You must specifiy the device used for "
" mounting with -D option, Run '%s -h' for option "
" information.", TCID);
- }
setup();
@@ -207,8 +205,8 @@ static void setup(void)
}
/* Call mount(2) */
- tst_resm(TINFO, "mount %s to %s fstype=%s", device, mntpoint, Fstype);
- TEST(mount(device, mntpoint, Fstype, 0, NULL));
+ tst_resm(TINFO, "mount %s to %s fstype=%s", device, mntpoint, fstype);
+ TEST(mount(device, mntpoint, fstype, 0, NULL));
/* check return code */
if (TEST_RETURN != 0) {
@@ -231,43 +229,37 @@ static void setup(void)
}
/* close the file we have open */
- if (close(fd) == -1) {
+ if (close(fd) == -1)
tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed", fname);
- }
fd_notify = myinotify_init();
if (fd_notify < 0) {
- if (errno == ENOSYS) {
+ if (errno == ENOSYS)
tst_brkm(TCONF, cleanup,
"inotify is not configured in this kernel.");
- } else {
+ else
tst_brkm(TBROK | TERRNO, cleanup,
"inotify_init failed");
- }
}
wd = myinotify_add_watch(fd_notify, fname, IN_ALL_EVENTS);
- if (wd < 0) {
+ if (wd < 0)
tst_brkm(TBROK | TERRNO, cleanup,
"inotify_add_watch (%d, %s, IN_ALL_EVENTS) failed.",
fd_notify, fname);
- };
-
}
static void cleanup(void)
{
- if (close(fd_notify) == -1) {
+ if (close(fd_notify) == -1)
tst_resm(TWARN | TERRNO, "close(%d) failed", fd_notify);
- }
if (mount_flag) {
TEST(umount(mntpoint));
- if (TEST_RETURN != 0) {
+ if (TEST_RETURN != 0)
tst_resm(TWARN | TTERRNO, "umount(%s) failed",
mntpoint);
- }
}
TEST_CLEANUP;
@@ -278,8 +270,8 @@ static void cleanup(void)
static void help(void)
{
printf("-T type : specifies the type of filesystem to be mounted."
- " Default ext2. \n");
- printf("-D device : device used for mounting \n");
+ " Default ext2.\n");
+ printf("-D device : device used for mounting.\n");
}
#else
--
1.8.1
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next reply other threads:[~2013-07-16 3:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-16 3:09 DAN LI [this message]
2013-07-16 13:05 ` [LTP] [PATCH] inotify/inotify03.c: cleanup a parameter-passing error chrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51E4B956.9020708@cn.fujitsu.com \
--to=li.dan@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox