Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 43973
b: refs/heads/master
c: d2f7bf1
h: refs/heads/master
i:
  43971: 5ffb4dc
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Dec 10, 2006
1 parent 71370c3 commit 9250c8f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4a7864ca638e0a38307962ee8ef122822a351b65
refs/heads/master: d2f7bf13461e8ead863126ee1e8ba92105959ecc
44 changes: 29 additions & 15 deletions trunk/Documentation/accounting/getdelays.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Copyright (C) Balbir Singh, IBM Corp. 2006
* Copyright (c) Jay Lan, SGI. 2006
*
* Compile with
* gcc -I/usr/src/linux/include getdelays.c -o getdelays
*/

#include <stdio.h>
Expand Down Expand Up @@ -35,13 +37,19 @@
#define NLA_DATA(na) ((void *)((char*)(na) + NLA_HDRLEN))
#define NLA_PAYLOAD(len) (len - NLA_HDRLEN)

#define err(code, fmt, arg...) do { printf(fmt, ##arg); exit(code); } while (0)
int done = 0;
int rcvbufsz=0;

char name[100];
int dbg=0, print_delays=0;
#define err(code, fmt, arg...) \
do { \
fprintf(stderr, fmt, ##arg); \
exit(code); \
} while (0)

int done;
int rcvbufsz;
char name[100];
int dbg;
int print_delays;
__u64 stime, utime;

#define PRINTF(fmt, arg...) { \
if (dbg) { \
printf(fmt, ##arg); \
Expand Down Expand Up @@ -78,8 +86,9 @@ static int create_nl_socket(int protocol)
if (rcvbufsz)
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
&rcvbufsz, sizeof(rcvbufsz)) < 0) {
printf("Unable to set socket rcv buf size to %d\n",
rcvbufsz);
fprintf(stderr, "Unable to set socket rcv buf size "
"to %d\n",
rcvbufsz);
return -1;
}

Expand Down Expand Up @@ -277,7 +286,7 @@ int main(int argc, char *argv[])
mypid = getpid();
id = get_family_id(nl_sd);
if (!id) {
printf("Error getting family id, errno %d", errno);
fprintf(stderr, "Error getting family id, errno %d\n", errno);
goto err;
}
PRINTF("family id %d\n", id);
Expand All @@ -288,7 +297,7 @@ int main(int argc, char *argv[])
&cpumask, strlen(cpumask) + 1);
PRINTF("Sent register cpumask, retval %d\n", rc);
if (rc < 0) {
printf("error sending register cpumask\n");
fprintf(stderr, "error sending register cpumask\n");
goto err;
}
}
Expand All @@ -298,7 +307,7 @@ int main(int argc, char *argv[])
cmd_type, &tid, sizeof(__u32));
PRINTF("Sent pid/tgid, retval %d\n", rc);
if (rc < 0) {
printf("error sending tid/tgid cmd\n");
fprintf(stderr, "error sending tid/tgid cmd\n");
goto done;
}
}
Expand All @@ -310,13 +319,15 @@ int main(int argc, char *argv[])
PRINTF("received %d bytes\n", rep_len);

if (rep_len < 0) {
printf("nonfatal reply error: errno %d\n", errno);
fprintf(stderr, "nonfatal reply error: errno %d\n",
errno);
continue;
}
if (msg.n.nlmsg_type == NLMSG_ERROR ||
!NLMSG_OK((&msg.n), rep_len)) {
struct nlmsgerr *err = NLMSG_DATA(&msg);
printf("fatal reply error, errno %d\n", err->error);
fprintf(stderr, "fatal reply error, errno %d\n",
err->error);
goto done;
}

Expand Down Expand Up @@ -365,7 +376,9 @@ int main(int argc, char *argv[])
goto done;
break;
default:
printf("Unknown nested nla_type %d\n", na->nla_type);
fprintf(stderr, "Unknown nested"
" nla_type %d\n",
na->nla_type);
break;
}
len2 += NLA_ALIGN(na->nla_len);
Expand All @@ -374,7 +387,8 @@ int main(int argc, char *argv[])
break;

default:
printf("Unknown nla_type %d\n", na->nla_type);
fprintf(stderr, "Unknown nla_type %d\n",
na->nla_type);
break;
}
na = (struct nlattr *) (GENLMSG_DATA(&msg) + len);
Expand Down

0 comments on commit 9250c8f

Please sign in to comment.