diff options
author | Balbir Singh <balbir@in.ibm.com> | 2006-10-01 02:28:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-01 03:39:29 -0400 |
commit | 7d1bdca9b06acb3df07329eaff72d5eaf1543287 (patch) | |
tree | 1e5b706964002cc6bfc42bc34f9be7f85382fb84 /Documentation/accounting/getdelays.c | |
parent | 0ae646845b603e9df5711084436d389f8371ffb3 (diff) |
[PATCH] Fix getdelays.c - cpumask length and error reporting
Fix the length passed while (un)registering cpumask. We were passing sizeof
the array, make it strlen().
Error value printed in fatal errors should be derived from the message. The
message contains an nlmsgerr embedded with an error value. We must report
that value to the user.
Signed-off-by: Balbir Singh <balbir@in.ibm.com>
Cc: Jamal Hadi <hadi@cyberus.ca>
Cc: Shailabh Nagar <nagar@watson.ibm.com>
Cc: Thomas Graf <tgraf@suug.ch>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jay Lan <jlan@engr.sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'Documentation/accounting/getdelays.c')
-rw-r--r-- | Documentation/accounting/getdelays.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c index 795ca3911cc5..b11792abd6b6 100644 --- a/Documentation/accounting/getdelays.c +++ b/Documentation/accounting/getdelays.c | |||
@@ -285,7 +285,7 @@ int main(int argc, char *argv[]) | |||
285 | if (maskset) { | 285 | if (maskset) { |
286 | rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, | 286 | rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, |
287 | TASKSTATS_CMD_ATTR_REGISTER_CPUMASK, | 287 | TASKSTATS_CMD_ATTR_REGISTER_CPUMASK, |
288 | &cpumask, sizeof(cpumask)); | 288 | &cpumask, strlen(cpumask) + 1); |
289 | PRINTF("Sent register cpumask, retval %d\n", rc); | 289 | PRINTF("Sent register cpumask, retval %d\n", rc); |
290 | if (rc < 0) { | 290 | if (rc < 0) { |
291 | printf("error sending register cpumask\n"); | 291 | printf("error sending register cpumask\n"); |
@@ -315,7 +315,8 @@ int main(int argc, char *argv[]) | |||
315 | } | 315 | } |
316 | if (msg.n.nlmsg_type == NLMSG_ERROR || | 316 | if (msg.n.nlmsg_type == NLMSG_ERROR || |
317 | !NLMSG_OK((&msg.n), rep_len)) { | 317 | !NLMSG_OK((&msg.n), rep_len)) { |
318 | printf("fatal reply error, errno %d\n", errno); | 318 | struct nlmsgerr *err = NLMSG_DATA(&msg); |
319 | printf("fatal reply error, errno %d\n", err->error); | ||
319 | goto done; | 320 | goto done; |
320 | } | 321 | } |
321 | 322 | ||
@@ -383,7 +384,7 @@ done: | |||
383 | if (maskset) { | 384 | if (maskset) { |
384 | rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, | 385 | rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, |
385 | TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK, | 386 | TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK, |
386 | &cpumask, sizeof(cpumask)); | 387 | &cpumask, strlen(cpumask) + 1); |
387 | printf("Sent deregister mask, retval %d\n", rc); | 388 | printf("Sent deregister mask, retval %d\n", rc); |
388 | if (rc < 0) | 389 | if (rc < 0) |
389 | err(rc, "error sending deregister cpumask\n"); | 390 | err(rc, "error sending deregister cpumask\n"); |