Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | samples/ftrace/sample-trace-array.c | static int simple_thread(void *arg) {
int count = 0;
unsigned long delay = msecs_to_jiffies(5000);
trace_array_set_clr_event(tr, "sample-subsystem", "sample_event", true);
/*
* Adding timer - mytimer. This timer will disable tracing after
* delay seconds.
*
*/
add_timer(&mytimer);
mod_timer(&m... | [
1,
0
] |
Linux Kernel | samples/ftrace/sample-trace-array.c | static void __exit sample_trace_array_exit(void) {
kthread_stop(simple_tsk);
trace_array_destroy(tr);
} | [
0,
0
] |
Linux Kernel | samples/kdb/kdb_hello.c | static int __init kdb_hello_cmd_init(void) {
kdb_register(&hello_cmd);
return 0;
} | [
0,
0
] |
Linux Kernel | samples/kfifo/bytestream-example.c |
static ssize_t fifo_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) {
int ret;
unsigned int copied;
if (mutex_lock_interruptible(&write_access))
return -ERESTARTSYS;
ret = kfifo_from_user(&test, buf, count, &copied);
mutex_unlock(&write_access);
... | [
0,
0
] |
Linux Kernel | samples/kfifo/inttype-example.c |
static ssize_t fifo_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos) {
int ret;
unsigned int copied;
if (mutex_lock_interruptible(&read_access))
return -ERESTARTSYS;
ret = kfifo_to_user(&test, buf, count, &copied);
mutex_unlock(&read_access);
if (ret)
... | [
0,
0
] |
Linux Kernel | samples/kfifo/record-example.c |
static void __exit example_exit(void) {
remove_proc_entry(PROC_FIFO, NULL);
#ifdef DYNAMIC
kfifo_free(&test);
#endif
} | [
0,
0
] |
Linux Kernel | samples/kobject/kset-example.c | static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr,
char *buf) {
return sysfs_emit(buf, "%d\n", foo_obj->foo);
} | [
0,
0
] |
Linux Kernel | samples/kobject/kset-example.c | static struct foo_obj *create_foo_obj(const char *name) {
struct foo_obj *foo;
int retval;
foo = kzalloc(sizeof(*foo), GFP_KERNEL);
if (!foo)
return NULL;
/*
* As we have a kset for this kobject, we need to set it before calling
* the kobject core.
*/
foo->kobj.kset = example_kset;
/*
*... | [
0,
0
] |
Linux Kernel | samples/kobject/kset-example.c | static int __init example_init(void) {
example_kset = kset_create_and_add("kset_example", NULL, kernel_kobj);
if (!example_kset)
return -ENOMEM;
/*
* Create three objects and register them with our kset
*/
foo_obj = create_foo_obj("foo");
if (!foo_obj)
goto foo_error;
bar_obj = create_foo_o... | [
0,
0
] |
Linux Kernel | samples/kprobes/kprobe_example.c |
static int __init kprobe_init(void) {
int ret;
kp.pre_handler = handler_pre;
kp.post_handler = handler_post;
ret = register_kprobe(&kp);
if (ret < 0) {
pr_err("register_kprobe failed, returned %d\n", ret);
return ret;
}
pr_info("Planted kprobe at %p\n", kp.addr);
return 0;
} | [
0,
0
] |
Linux Kernel | samples/kprobes/kprobe_example.c |
static void __exit kprobe_exit(void) {
unregister_kprobe(&kp);
pr_info("kprobe at %p unregistered\n", kp.addr);
} | [
0,
0
] |
Linux Kernel | samples/landlock/sandboxer.c | static inline int landlock_add_rule(const int ruleset_fd,
const enum landlock_rule_type rule_type,
const void *const rule_attr,
const __u32 flags) {
return syscall(__NR_landlock_add_rule, ruleset_fd, rule_type,... | [
0,
0
] |
Linux Kernel | samples/landlock/sandboxer.c | static int parse_path(char *env_path, const char ***const path_list) {
int i, num_paths = 0;
if (env_path) {
num_paths++;
for (i = 0; env_path[i]; i++) {
if (env_path[i] == ENV_PATH_TOKEN[0])
num_paths++;
}
}
*path_list = malloc(num_paths * sizeof(**path_list));
for (i = 0; i < num_... | [
1,
0
] |
Linux Kernel | samples/livepatch/livepatch-callbacks-busymod.c |
static void livepatch_callbacks_mod_exit(void) {
cancel_delayed_work_sync(&work);
pr_info("%s\n", __func__);
} | [
0,
0
] |
Linux Kernel | samples/livepatch/livepatch-callbacks-demo.c | static void post_unpatch_callback(struct klp_object *obj) {
callback_info(__func__, obj);
} | [
0,
0
] |
Linux Kernel | samples/livepatch/livepatch-callbacks-demo.c |
static int livepatch_callbacks_demo_init(void) {
return klp_enable_patch(&patch);
} | [
0,
0
] |
Linux Kernel | samples/livepatch/livepatch-shadow-fix1.c | static int shadow_leak_ctor(void *obj, void *shadow_data, void *ctor_data) {
int **shadow_leak = shadow_data;
int **leak = ctor_data;
if (!ctor_data)
return -EINVAL;
*shadow_leak = *leak;
return 0;
} | [
0,
0
] |
Linux Kernel | samples/livepatch/livepatch-shadow-fix1.c | static struct dummy *livepatch_fix1_dummy_alloc(void) {
struct dummy *d;
int *leak;
int **shadow_leak;
d = kzalloc(sizeof(*d), GFP_KERNEL);
if (!d)
return NULL;
d->jiffies_expire = jiffies + msecs_to_jiffies(1000 * EXPIRE_PERIOD);
leak = kzalloc(sizeof(*leak), GFP_KERNEL);
if (!leak)
goto err... | [
1,
0
] |
Linux Kernel | samples/livepatch/livepatch-shadow-fix1.c |
static void livepatch_fix1_dummy_leak_dtor(void *obj, void *shadow_data) {
void *d = obj;
int **shadow_leak = shadow_data;
pr_info("%s: dummy @ %p, prevented leak @ %p\n", __func__, d, *shadow_leak);
kfree(*shadow_leak);
} | [
0,
0
] |
Linux Kernel | samples/livepatch/livepatch-shadow-fix2.c | static void livepatch_shadow_fix2_exit(void) {
klp_shadow_free_all(SV_COUNTER, NULL);
} | [
0,
0
] |
Linux Kernel | samples/livepatch/livepatch-shadow-mod.c |
__used noinline void dummy_free(struct dummy *d) {
pr_info("%s: dummy @ %p, expired = %lx\n", __func__, d, d->jiffies_expire);
kfree(d);
} | [
0,
0
] |
Linux Kernel | samples/mei/mei-amt-version.c |
static void mei_deinit(struct mei *cl) {
if (cl->fd != -1)
close(cl->fd);
cl->fd = -1;
cl->buf_size = 0;
cl->prot_ver = 0;
cl->initialized = false;
} | [
1,
0
] |
Linux Kernel | samples/mei/mei-amt-version.c | static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer,
ssize_t len, unsigned long timeout) {
ssize_t written;
ssize_t rc;
mei_msg(me, "call write length = %zd\n", len);
written = write(me->fd, buffer, len);
if (written < 0) {
rc = -errno;
mei_err(me, "wr... | [
0,
0
] |
Linux Kernel | samples/mei/mei-amt-version.c |
static uint32_t amt_get_code_versions(struct amt_host_if *cmd,
struct amt_code_versions *versions) {
struct amt_host_if_resp_header *response = NULL;
uint32_t status;
status = amt_host_if_call(cmd, (const unsigned char *)&CODE_VERSION_REQ,
sizeo... | [
1,
0
] |
Linux Kernel | samples/pidfd/pidfd-metadata.c |
static pid_t pidfd_clone(int flags, int *pidfd) {
size_t stack_size = 1024;
char *stack[1024] = {0};
#ifdef __ia64__
return __clone2(do_child, stack, stack_size, flags | SIGCHLD, NULL, pidfd);
#else
return clone(do_child, stack + stack_size, flags | SIGCHLD, NULL, pidfd);
#endif
} | [
0,
0
] |
Linux Kernel | samples/pidfd/pidfd-metadata.c |
static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
unsigned int flags) {
return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags);
} | [
0,
0
] |
Linux Kernel | samples/qmi/qmi_sample_client.c |
static int qmi_sample_probe(struct platform_device *pdev) {
struct sockaddr_qrtr *sq;
struct qmi_sample *sample;
char path[20];
int ret;
sample = devm_kzalloc(&pdev->dev, sizeof(*sample), GFP_KERNEL);
if (!sample)
return -ENOMEM;
ret = qmi_handle_init(&sample->qmi, TEST_DATA_REQ_MAX_MSG_LEN_V01, NU... | [
1,
0
] |
Linux Kernel | samples/qmi/qmi_sample_client.c |
static int qmi_sample_new_server(struct qmi_handle *qmi,
struct qmi_service *service) {
struct platform_device *pdev;
struct sockaddr_qrtr sq = {AF_QIPCRTR, service->node, service->port};
int ret;
pdev = platform_device_alloc("qmi_sample_client", PLATFORM_DEVID_AUTO);
if (!p... | [
1,
0
] |
Linux Kernel | samples/qmi/qmi_sample_client.c |
static void qmi_sample_exit(void) {
qmi_handle_release(&lookup_client);
platform_driver_unregister(&qmi_sample_driver);
debugfs_remove(qmi_debug_dir);
} | [
0,
0
] |
Linux Kernel | samples/rpmsg/rpmsg_client_sample.c | static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len,
void *priv, u32 src) {
int ret;
struct instance_data *idata = dev_get_drvdata(&rpdev->dev);
dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", ++idata->rx_count,
src);
print_hex_dump_debug(__f... | [
1,
0
] |
Linux Kernel | samples/seccomp/bpf-direct.c | static void emulator(int nr, siginfo_t *info, void *void_context) {
ucontext_t *ctx = (ucontext_t *)(void_context);
int syscall;
char *buf;
ssize_t bytes;
size_t len;
if (info->si_code != SYS_SECCOMP)
return;
if (!ctx)
return;
syscall = ctx->uc_mcontext.gregs[REG_SYSCALL];
buf = (char *)ctx->u... | [
0,
0
] |
Linux Kernel | samples/seccomp/bpf-helper.c | int bpf_resolve_jumps(struct bpf_labels *labels, struct sock_filter *filter,
size_t count) {
size_t i;
if (count < 1 || count > BPF_MAXINSNS)
return -1;
for (i = 0; i < count; ++i) {
size_t offset = count - i - 1;
struct sock_filter *instr = &filter[offset];
if (instr->code... | [
1,
0
] |
Linux Kernel | samples/trace_events/trace-events-sample.c | int foo_bar_reg(void) {
mutex_lock(&thread_mutex);
if (simple_thread_cnt++)
goto out;
pr_info("Starting thread for foo_bar_fn\n");
simple_tsk_fn = kthread_run(simple_thread_fn, NULL, "event-sample-fn");
out:
mutex_unlock(&thread_mutex);
return 0;
} | [
0,
0
] |
Linux Kernel | samples/trace_events/trace_custom_sched.c |
static void __exit trace_sched_exit(void) {} | [
0,
0
] |
Linux Kernel | samples/uhid/uhid-example.c |
static void destroy(int fd) {
struct uhid_event ev;
memset(&ev, 0, sizeof(ev));
ev.type = UHID_DESTROY;
uhid_write(fd, &ev);
} | [
1,
0
] |
Linux Kernel | samples/uhid/uhid-example.c | static void handle_output(struct uhid_event *ev) {
if (ev->u.output.rtype != UHID_OUTPUT_REPORT)
return;
/* LED reports have length 2 bytes */
if (ev->u.output.size != 2)
return;
/* first byte is report-id which is 0x02 for LEDs in our rdesc */
if (ev->u.output.data[0] != 0x2)
return;
/* print... | [
0,
0
] |
Linux Kernel | samples/uhid/uhid-example.c |
static int keyboard(int fd) {
char buf[128];
ssize_t ret, i;
ret = read(STDIN_FILENO, buf, sizeof(buf));
if (ret == 0) {
fprintf(stderr, "Read HUP on stdin\n");
return -EFAULT;
} else if (ret < 0) {
fprintf(stderr, "Cannot read stdin: %m\n");
return -errno;
}
for (i = 0; i < ret; ++i) {... | [
1,
0
] |
Linux Kernel | samples/user_events/example.c |
static int event_status(long **status) {
int fd = open(status_file, O_RDONLY);
*status = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ, MAP_SHARED, fd, 0);
close(fd);
if (*status == MAP_FAILED)
return -1;
return 0;
} | [
0,
0
] |
Linux Kernel | samples/user_events/example.c | int main(int argc, char **argv) {
int data_fd, write;
long index, mask;
long *status_page;
struct iovec io[2];
__u32 count = 0;
if (event_status(&status_page) == -1)
return errno;
data_fd = open(data_file, O_RDWR);
if (event_reg(data_fd, "test u32 count", &index, &mask, &write) == -1)
return ... | [
1,
0
] |
Linux Kernel | samples/v4l/v4l2-pci-skeleton.c |
static inline struct skel_buffer *to_skel_buffer(struct vb2_v4l2_buffer *vbuf) {
return container_of(vbuf, struct skel_buffer, vb);
} | [
0,
0
] |
Linux Kernel | samples/v4l/v4l2-pci-skeleton.c | static void skeleton_fill_pix_format(struct skeleton *skel,
struct v4l2_pix_format *pix) {
pix->pixelformat = V4L2_PIX_FMT_YUYV;
if (skel->input == 0) {
pix->width = 720;
pix->height = (skel->std & V4L2_STD_525_60) ? 480 : 576;
pix->field = V4L2_FIELD_INTERLACED;
... | [
1,
0
] |
Linux Kernel | samples/v4l/v4l2-pci-skeleton.c | static int skeleton_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f) {
struct skeleton *skel = video_drvdata(file);
int ret;
ret = skeleton_try_fmt_vid_cap(file, priv, f);
if (ret)
return ret;
if (vb2_is_busy(&skel->queue))
return -EBUSY;
/* TO... | [
0,
1
] |
Linux Kernel | samples/v4l/v4l2-pci-skeleton.c |
static int skeleton_enum_input(struct file *file, void *priv,
struct v4l2_input *i) {
if (i->index > 1)
return -EINVAL;
i->type = V4L2_INPUT_TYPE_CAMERA;
if (i->index == 0) {
i->std = SKEL_TVNORMS;
strlcpy(i->name, "S-Video", sizeof(i->name));
i->capabilities = V4L... | [
1,
0
] |
Linux Kernel | samples/v4l/v4l2-pci-skeleton.c | static int skeleton_s_input(struct file *file, void *priv, unsigned int i) {
struct skeleton *skel = video_drvdata(file);
if (i > 1)
return -EINVAL;
if (vb2_is_busy(&skel->queue))
return -EBUSY;
skel->input = i;
/*
* Update tvnorms. The tvnorms value is used by the core to implement
* VIDIOC_... | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c |
static void mbochs_create_config_space(struct mdev_state *mdev_state) {
STORE_LE16((u16 *)&mdev_state->vconfig[PCI_VENDOR_ID], 0x1234);
STORE_LE16((u16 *)&mdev_state->vconfig[PCI_DEVICE_ID], 0x1111);
STORE_LE16((u16 *)&mdev_state->vconfig[PCI_SUBSYSTEM_VENDOR_ID],
PCI_SUBVENDOR_ID_REDHAT_QUMRANET);
... | [
1,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c |
static bool mbochs_modes_equal(struct mbochs_mode *mode1,
struct mbochs_mode *mode2) {
return memcmp(mode1, mode2, sizeof(struct mbochs_mode)) == 0;
} | [
1,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c |
static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count) {
struct device *dev = mdev_dev(mdev_state->mdev);
int index = (offset - PCI_BASE_ADDRESS_0) / 0x04;
u32 cfg_addr;
switch (offset) {
case PCI_BASE_ADDRESS_0:
case PCI_BASE_ADD... | [
1,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c | static void handle_mmio_read(struct mdev_state *mdev_state, u16 offset,
char *buf, u32 count) {
struct device *dev = mdev_dev(mdev_state->mdev);
struct vfio_region_gfx_edid *edid;
u16 reg16 = 0;
int index;
switch (offset) {
case 0x000 ... 0x3ff:
edid = &mdev_state->edid_reg... | [
1,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c |
static struct sg_table *mbochs_map_dmabuf(struct dma_buf_attachment *at,
enum dma_data_direction direction) {
struct mbochs_dmabuf *dmabuf = at->dmabuf->priv;
struct device *dev = mdev_dev(dmabuf->mdev_state->mdev);
struct sg_table *sg;
dev_dbg(dev, "%s: %d\n", __func... | [
1,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c |
static struct mbochs_dmabuf *mbochs_dmabuf_alloc(struct mdev_state *mdev_state,
struct mbochs_mode *mode) {
struct mbochs_dmabuf *dmabuf;
pgoff_t page_offset, pg;
WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
dmabuf = kzalloc(sizeof(struct mbochs_dmabuf), ... | [
1,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c |
static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf) {
struct mdev_state *mdev_state = dmabuf->mdev_state;
struct device *dev = mdev_state->vdev.dev;
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
struct dma_buf *buf;
WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
if (!IS_ALIGNED(dmabuf->mode.offset, ... | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mbochs.c |
static int mbochs_get_device_info(struct vfio_device_info *dev_info) {
dev_info->flags = VFIO_DEVICE_FLAGS_PCI;
dev_info->num_regions = MBOCHS_NUM_REGIONS;
dev_info->num_irqs = VFIO_PCI_NUM_IRQS;
return 0;
} | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mdpy-fb.c |
static void mdpy_fb_destroy(struct fb_info *info) {
if (info->screen_base)
iounmap(info->screen_base);
} | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mdpy.c |
static void mdpy_release_dev(struct vfio_device *vdev) {
struct mdev_state *mdev_state = container_of(vdev, struct mdev_state, vdev);
vfree(mdev_state->memblk);
kfree(mdev_state->vconfig);
vfio_free_device(vdev);
} | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mdpy.c |
static void mdpy_remove(struct mdev_device *mdev) {
struct mdev_state *mdev_state = dev_get_drvdata(&mdev->dev);
dev_info(&mdev->dev, "%s\n", __func__);
vfio_unregister_group_dev(&mdev_state->vdev);
vfio_put_device(&mdev_state->vdev);
} | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mdpy.c |
static int mdpy_get_region_info(struct mdev_state *mdev_state,
struct vfio_region_info *region_info,
u16 *cap_type_id, void **cap_type) {
if (region_info->index >= VFIO_PCI_NUM_REGIONS &&
region_info->index != MDPY_DISPLAY_REGION)
return -EINV... | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mtty.c | static void dump_buffer(u8 *buf, uint32_t count) {
#if defined(DEBUG)
int i;
pr_info("Buffer:\n");
for (i = 0; i < count; i++) {
pr_info("%2x ", *(buf + i));
if ((i + 1) % 16 == 0)
pr_info("\n");
}
#endif
} | [
1,
0
] |
Linux Kernel | samples/vfio-mdev/mtty.c | static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
u8 *buf, u32 count) {
u32 cfg_addr, bar_mask, bar_index = 0;
switch (offset) {
case 0x04:
case 0x06: /* device status */
/* do nothing */
break;
case 0x3c: /* interrupt line */
mdev_state-... | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mtty.c |
static int mtty_probe(struct mdev_device *mdev) {
struct mdev_state *mdev_state;
int ret;
mdev_state = vfio_alloc_device(mdev_state, vdev, &mdev->dev, &mtty_dev_ops);
if (IS_ERR(mdev_state))
return PTR_ERR(mdev_state);
ret = vfio_register_emulated_iommu_dev(&mdev_state->vdev);
if (ret)
goto err_p... | [
0,
0
] |
Linux Kernel | samples/vfio-mdev/mtty.c |
static int mtty_get_device_info(struct vfio_device_info *dev_info) {
dev_info->flags = VFIO_DEVICE_FLAGS_PCI;
dev_info->num_regions = VFIO_PCI_NUM_REGIONS;
dev_info->num_irqs = VFIO_PCI_NUM_IRQS;
return 0;
} | [
0,
0
] |
Linux Kernel | samples/vfs/test-fsmount.c |
static void check_messages(int fd) {
char buf[4096];
int err, n;
err = errno;
for (;;) {
n = read(fd, buf, sizeof(buf));
if (n < 0)
break;
n -= 2;
switch (buf[0]) {
case 'e':
fprintf(stderr, "Error: %*.*s\n", n, n, buf + 2);
break;
case 'w':
fprintf(stderr, "W... | [
1,
0
] |
Linux Kernel | samples/vfs/test-fsmount.c |
static inline int fsmount(int fsfd, unsigned int flags, unsigned int ms_flags) {
return syscall(__NR_fsmount, fsfd, flags, ms_flags);
} | [
0,
0
] |
Linux Kernel | samples/vfs/test-fsmount.c |
static inline int fsconfig(int fsfd, unsigned int cmd, const char *key,
const void *val, int aux) {
return syscall(__NR_fsconfig, fsfd, cmd, key, val, aux);
} | [
0,
0
] |
Linux Kernel | samples/vfs/test-statx.c |
static void print_time(const char *field, struct statx_timestamp *ts) {
struct tm tm;
time_t tim;
char buffer[100];
int len;
tim = ts->tv_sec;
if (!localtime_r(&tim, &tm)) {
perror("localtime_r");
exit(1);
}
len = strftime(buffer, 100, "%F %T", &tm);
if (len == 0) {
perror("strftime");
... | [
0,
0
] |
Linux Kernel | samples/watch_queue/watch_test.c |
int main(int argc, char **argv) {
int pipefd[2], fd;
if (pipe2(pipefd, O_NOTIFICATION_PIPE) == -1) {
perror("pipe2");
exit(1);
}
fd = pipefd[0];
if (ioctl(fd, IOC_WATCH_QUEUE_SET_SIZE, BUF_SIZE) == -1) {
perror("watch_queue(size)");
exit(1);
}
if (ioctl(fd, IOC_WATCH_QUEUE_SET_FILTER, ... | [
0,
0
] |
Linux Kernel | scripts/asn1_compiler.c | static void parse(void) {
struct token *cursor;
struct type *type;
type = type_list;
do {
cursor = type->name;
if (cursor[0].token_type != TOKEN_TYPE_NAME ||
cursor[1].token_type != TOKEN_ASSIGNMENT)
abort();
cursor += 2;
type->element = parse_type(&cursor, type[1].name, NULL);
... | [
1,
0
] |
Linux Kernel | scripts/asn1_compiler.c |
static struct element *alloc_elem(void) {
struct element *e = calloc(1, sizeof(*e));
if (!e) {
perror(NULL);
exit(1);
}
e->list_next = element_list;
element_list = e;
return e;
} | [
1,
0
] |
Linux Kernel | scripts/asn1_compiler.c | static struct element *parse_compound(struct token **_cursor, struct token *end,
int alternates) {
struct element *children, **child_p = &children, *element;
struct token *cursor = *_cursor, *name;
if (cursor->token_type != TOKEN_OPEN_CURLY) {
fprintf(stderr, "%s:%d: Exp... | [
0,
0
] |
Linux Kernel | scripts/basic/fixdep.c |
static void usage(void) {
fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
exit(1);
} | [
0,
0
] |
Linux Kernel | scripts/basic/fixdep.c | static int str_ends_with(const char *s, int slen, const char *sub) {
int sublen = strlen(sub);
if (sublen > slen)
return 0;
return !memcmp(s + slen - sublen, sub, sublen);
} | [
0,
0
] |
Linux Kernel | scripts/basic/fixdep.c |
static void parse_config_file(const char *p) {
const char *q, *r;
const char *start = p;
while ((p = strstr(p, "CONFIG_"))) {
if (p > start && (isalnum(p[-1]) || p[-1] == '_')) {
p += 7;
continue;
}
p += 7;
q = p;
while (isalnum(*q) || *q == '_')
q++;
if (str_ends_with(... | [
1,
0
] |
Linux Kernel | scripts/basic/fixdep.c |
static void *read_file(const char *filename) {
struct stat st;
int fd;
char *buf;
fd = open(filename, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "fixdep: error opening file: ");
perror(filename);
exit(2);
}
if (fstat(fd, &st) < 0) {
fprintf(stderr, "fixdep: error fstat'ing file: ");
pe... | [
1,
0
] |
Linux Kernel | scripts/basic/fixdep.c | int main(int argc, char *argv[]) {
const char *depfile, *target, *cmdline;
void *buf;
if (argc != 4)
usage();
depfile = argv[1];
target = argv[2];
cmdline = argv[3];
printf("cmd_%s := %s\n\n", target, cmdline);
buf = read_file(depfile);
parse_dep_file(buf, target);
free(buf);
fflush(stdou... | [
1,
0
] |
Linux Kernel | scripts/dtc/checks.c |
static void check_nodes_props(struct check *c, struct dt_info *dti,
struct node *node) {
struct node *child;
TRACE(c, "%s", node->fullpath);
if (c->fn)
c->fn(c, dti, node);
for_each_child(node, child) check_nodes_props(c, dti, child);
} | [
0,
0
] |
Linux Kernel | scripts/dtc/checks.c |
static bool run_check(struct check *c, struct dt_info *dti) {
struct node *dt = dti->dt;
bool error = false;
int i;
assert(!c->inprogress);
if (c->status != UNCHECKED)
goto out;
c->inprogress = true;
for (i = 0; i < c->num_prereqs; i++) {
struct check *prq = c->prereq[i];
error = error ||... | [
0,
0
] |
Linux Kernel | scripts/dtc/checks.c | static inline void check_always_fail(struct check *c, struct dt_info *dti,
struct node *node) {
FAIL(c, dti, node, "always_fail check");
} | [
0,
0
] |
Linux Kernel | scripts/dtc/checks.c | static void check_is_cell(struct check *c, struct dt_info *dti,
struct node *node) {
struct property *prop;
char *propname = c->data;
prop = get_property(node, propname);
if (!prop)
return;
if (prop->val.len != sizeof(cell_t))
FAIL_PROP(c, dti, node, prop, "property is not ... | [
1,
0
] |
Linux Kernel | scripts/dtc/checks.c | static void check_reg_format(struct check *c, struct dt_info *dti,
struct node *node) {
struct property *prop;
int addr_cells, size_cells, entrylen;
prop = get_property(node, "reg");
if (!prop)
return;
if (!node->parent) {
FAIL(c, dti, node, "Root node has a \"reg\" prop... | [
1,
0
] |
Linux Kernel | scripts/dtc/checks.c | static void check_simple_bus_reg(struct check *c, struct dt_info *dti,
struct node *node) {
struct property *prop;
const char *unitname = get_unitname(node);
char unit_addr[17];
unsigned int size;
uint64_t reg = 0;
cell_t *cells = NULL;
if (!node->parent || (node->parent-... | [
1,
0
] |
Linux Kernel | scripts/dtc/checks.c | static void check_spi_bus_bridge(struct check *c, struct dt_info *dti,
struct node *node) {
int spi_addr_cells = 1;
if (strprefixeq(node->name, node->basenamelen, "spi")) {
node->bus = &spi_bus;
} else {
struct node *child;
if (node_addr_cells(node) != 1 || node_siz... | [
1,
0
] |
Linux Kernel | scripts/dtc/checks.c | static void check_unit_address_format(struct check *c, struct dt_info *dti,
struct node *node) {
const char *unitname = get_unitname(node);
if (node->parent && node->parent->bus)
return;
if (!unitname[0])
return;
if (!strncmp(unitname, "0x", 2)) {
FAIL(c, dti... | [
1,
0
] |
Linux Kernel | scripts/dtc/checks.c |
static bool node_is_disabled(struct node *node) {
struct property *prop;
prop = get_property(node, "status");
if (prop) {
char *str = prop->val.val;
if (streq("disabled", str))
return true;
}
return false;
} | [
0,
0
] |
Linux Kernel | scripts/dtc/checks.c |
static void check_chosen_node_bootargs(struct check *c, struct dt_info *dti,
struct node *node) {
struct property *prop;
if (!streq(node->name, "chosen"))
return;
prop = get_property(node, "bootargs");
if (!prop)
return;
c->data = prop->name;
check_is_strin... | [
0,
0
] |
Linux Kernel | scripts/dtc/checks.c |
static void check_provider_cells_property(struct check *c, struct dt_info *dti,
struct node *node) {
struct provider *provider = c->data;
struct property *prop;
prop = get_property(node, provider->prop_name);
if (!prop)
return;
check_property_phandle_args(c, dt... | [
0,
0
] |
Linux Kernel | scripts/dtc/checks.c | static void check_graph_nodes(struct check *c, struct dt_info *dti,
struct node *node) {
struct node *child;
for_each_child(node, child) {
if (!(strprefixeq(child->name, child->basenamelen, "endpoint") ||
get_property(child, "remote-endpoint")))
continue;
node... | [
1,
0
] |
Linux Kernel | scripts/dtc/checks.c |
static void check_graph_endpoint(struct check *c, struct dt_info *dti,
struct node *node) {
struct node *remote_node;
if (!node->parent || node->parent->bus != &graph_port_bus)
return;
if (!strprefixeq(node->name, node->basenamelen, "endpoint"))
FAIL(c, dti, node, "grap... | [
0,
0
] |
Linux Kernel | scripts/dtc/checks.c |
void parse_checks_option(bool warn, bool error, const char *arg) {
unsigned int i;
const char *name = arg;
bool enable = true;
if ((strncmp(arg, "no-", 3) == 0) || (strncmp(arg, "no_", 3) == 0)) {
name = arg + 3;
enable = false;
}
for (i = 0; i < ARRAY_SIZE(check_table); i++) {
struct check *... | [
0,
0
] |
Linux Kernel | scripts/dtc/data.c |
void data_free(struct data d) {
struct marker *m, *nm;
m = d.markers;
while (m) {
nm = m->next;
free(m->ref);
free(m);
m = nm;
}
if (d.val)
free(d.val);
} | [
1,
0
] |
Linux Kernel | scripts/dtc/data.c |
struct data data_copy_mem(const char *mem, int len) {
struct data d;
d = data_grow_for(empty_data, len);
d.len = len;
memcpy(d.val, mem, len);
return d;
} | [
1,
0
] |
Linux Kernel | scripts/dtc/data.c |
struct data data_append_data(struct data d, const void *p, int len) {
d = data_grow_for(d, len);
memcpy(d.val + d.len, p, len);
d.len += len;
return d;
} | [
1,
0
] |
Linux Kernel | scripts/dtc/data.c |
struct data data_append_integer(struct data d, uint64_t value, int bits) {
uint8_t value_8;
fdt16_t value_16;
fdt32_t value_32;
fdt64_t value_64;
switch (bits) {
case 8:
value_8 = value;
return data_append_data(d, &value_8, 1);
case 16:
value_16 = cpu_to_fdt16(value);
return data_append... | [
0,
0
] |
Linux Kernel | scripts/dtc/data.c |
struct data data_append_zeroes(struct data d, int len) {
d = data_grow_for(d, len);
memset(d.val + d.len, 0, len);
d.len += len;
return d;
} | [
1,
0
] |
Linux Kernel | scripts/dtc/data.c |
struct data data_append_align(struct data d, int align) {
int newlen = ALIGN(d.len, align);
return data_append_zeroes(d, newlen - d.len);
} | [
0,
0
] |
Linux Kernel | scripts/dtc/dtc.c |
static void fill_fullpaths(struct node *tree, const char *prefix) {
struct node *child;
const char *unit;
tree->fullpath = join_path(prefix, tree->name);
unit = strchr(tree->name, '@');
if (unit)
tree->basenamelen = unit - tree->name;
else
tree->basenamelen = strlen(tree->name);
for_each_child... | [
0,
0
] |
Linux Kernel | scripts/dtc/dtc.c |
static const char *guess_input_format(const char *fname, const char *fallback) {
struct stat statbuf;
fdt32_t magic;
FILE *f;
if (stat(fname, &statbuf) != 0)
return fallback;
if (S_ISDIR(statbuf.st_mode))
return "fs";
if (!S_ISREG(statbuf.st_mode))
return fallback;
f = fopen(fname, "r");
... | [
1,
0
] |
Linux Kernel | scripts/dtc/dtc.h |
static inline bool phandle_is_valid(cell_t phandle) {
return phandle != 0 && phandle != ~0U;
} | [
1,
0
] |
Linux Kernel | scripts/dtc/dtc.h |
static inline uint32_t dtb_ld32(const void *p) {
const uint8_t *bp = (const uint8_t *)p;
return ((uint32_t)bp[0] << 24) | ((uint32_t)bp[1] << 16) |
((uint32_t)bp[2] << 8) | bp[3];
} | [
0,
0
] |
Linux Kernel | scripts/dtc/fdtget.c | static int list_subnodes(const void *blob, int node) {
int nextoffset;
uint32_t tag; /* current tag */
int level = 0; /* keep track of nesting level */
const char *pathp;
int depth = 1; /* the assumed depth of this node */
while (level >= 0) {
tag = fdt_next_tag(blob, node, &nextoffset);
switch (t... | [
0,
0
] |
Linux Kernel | scripts/dtc/fdtoverlay.c | static void *apply_one(char *base, const char *overlay, size_t *buf_len,
const char *name) {
char *tmp = NULL;
char *tmpo;
int ret;
tmpo = xmalloc(fdt_totalsize(overlay));
do {
tmp = xrealloc(tmp, *buf_len);
ret = fdt_open_into(base, tmp, *buf_len);
if (ret) {
fprint... | [
1,
0
] |
Linux Kernel | scripts/dtc/fdtput.c | static void report_error(const char *name, int namelen, int err) {
if (namelen == -1)
namelen = strlen(name);
fprintf(stderr, "Error at '%1.*s': %s\n", namelen, name, fdt_strerror(err));
} | [
0,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.