1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-30 12:04:07 +00:00

- Document layout of KTR_STRUCT payload in a comment.

- Simplify ktrstruct() calling convention by having ktrstruct() use
  strlen() rather than requiring the caller to hand-code the length of
  constant strings.

MFC after:	1 month
This commit is contained in:
John Baldwin 2010-07-14 17:38:01 +00:00
parent 1d73ef9790
commit a3052d6e08
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=210064
2 changed files with 11 additions and 9 deletions

View File

@ -596,9 +596,8 @@ ktrcsw(out, user)
}
void
ktrstruct(name, namelen, data, datalen)
ktrstruct(name, data, datalen)
const char *name;
size_t namelen;
void *data;
size_t datalen;
{
@ -608,11 +607,10 @@ ktrstruct(name, namelen, data, datalen)
if (!data)
datalen = 0;
buflen = namelen + 1 + datalen;
buflen = strlen(name) + 1 + datalen;
buf = malloc(buflen, M_KTRACE, M_WAITOK);
bcopy(name, buf, namelen);
buf[namelen] = '\0';
bcopy(data, buf + namelen + 1, datalen);
strcpy(buf, name);
bcopy(data, buf + strlen(name) + 1, datalen);
if ((req = ktr_getrequest(KTR_STRUCT)) == NULL) {
free(buf, M_KTRACE);
return;

View File

@ -154,6 +154,10 @@ struct ktr_csw {
* KTR_STRUCT - misc. structs
*/
#define KTR_STRUCT 8
/*
* record contains null-terminated struct name followed by
* struct contents
*/
struct sockaddr;
struct stat;
@ -202,11 +206,11 @@ void ktrsysctl(int *name, u_int namelen);
void ktrsysret(int, int, register_t);
void ktrprocexit(struct thread *);
void ktruserret(struct thread *);
void ktrstruct(const char *, size_t, void *, size_t);
void ktrstruct(const char *, void *, size_t);
#define ktrsockaddr(s) \
ktrstruct("sockaddr", 8, (s), ((struct sockaddr *)(s))->sa_len)
ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len)
#define ktrstat(s) \
ktrstruct("stat", 4, (s), sizeof(struct stat))
ktrstruct("stat", (s), sizeof(struct stat))
#else