tools/testing/selftests/net/tcp_ao/lib/utils.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tcp_ao/lib/utils.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/tcp_ao/lib/utils.c- Extension
.c- Size
- 969 bytes
- Lines
- 57
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
aolib.hstring.h
Detected Declarations
function randomize_buffer
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include "aolib.h"
#include <string.h>
void randomize_buffer(void *buf, size_t buflen)
{
int *p = (int *)buf;
size_t words = buflen / sizeof(int);
size_t leftover = buflen % sizeof(int);
if (!buflen)
return;
while (words--)
*p++ = rand();
if (leftover) {
int tmp = rand();
memcpy(buf + buflen - leftover, &tmp, leftover);
}
}
__printf(3, 4) int test_echo(const char *fname, bool append,
const char *fmt, ...)
{
size_t len, written;
va_list vargs;
char *msg;
FILE *f;
f = fopen(fname, append ? "a" : "w");
if (!f)
return -errno;
va_start(vargs, fmt);
msg = test_snprintf(fmt, vargs);
va_end(vargs);
if (!msg) {
fclose(f);
return -1;
}
len = strlen(msg);
written = fwrite(msg, 1, len, f);
fclose(f);
free(msg);
return written == len ? 0 : -1;
}
const struct sockaddr_in6 addr_any6 = {
.sin6_family = AF_INET6,
};
const struct sockaddr_in addr_any4 = {
.sin_family = AF_INET,
};
Annotation
- Immediate include surface: `aolib.h`, `string.h`.
- Detected declarations: `function randomize_buffer`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.