cregit-Linux how code gets into the kernel

Release 4.18 scripts/kconfig/util.c

Directory: scripts/kconfig
/*
 * Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org>
 * Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org>
 *
 * Released under the terms of the GNU GPL v2.0.
 */

#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "lkc.h"

/* file already present in list? If not add it */

struct file *file_lookup(const char *name) { struct file *file; for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { return file; } } file = xmalloc(sizeof(*file)); memset(file, 0, sizeof(*file)); file->name = xstrdup(name); file->next = file_list; file_list = file; return file; }

Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg8992.71%125.00%
Masahiro Yamada44.17%125.00%
Arnaud Lacombe22.08%125.00%
Alan Cox11.04%125.00%
Total96100.00%4100.00%

/* write a dependency file as used by kbuild to track dependencies */
int file_write_dep(const char *name) { struct file *file; FILE *out; if (!name) name = ".kconfig.d"; out = fopen("..config.tmp", "w"); if (!out) return 1; fprintf(out, "deps_config := \\\n"); for (file = file_list; file; file = file->next) { if (file->next) fprintf(out, "\t%s \\\n", file->name); else fprintf(out, "\t%s\n", file->name); } fprintf(out, "\n%s: \\\n" "\t$(deps_config)\n\n", conf_get_autoconfig_name()); env_write_dep(out, conf_get_autoconfig_name()); fprintf(out, "\n$(deps_config): ;\n"); fclose(out); rename("..config.tmp", name); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg11885.51%233.33%
Roman Zippel139.42%233.33%
Markus Heidelberg64.35%116.67%
Masahiro Yamada10.72%116.67%
Total138100.00%6100.00%

/* Allocate initial growable string */
struct gstr str_new(void) { struct gstr gs; gs.s = xmalloc(sizeof(char) * 64); gs.len = 64; gs.max_width = 0; strcpy(gs.s, "\0"); return gs; }

Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg4284.00%125.00%
Vadim Bendebury612.00%125.00%
Alan Cox12.00%125.00%
Christophe Jaillet12.00%125.00%
Total50100.00%4100.00%

/* Free storage for growable string */
void str_free(struct gstr *gs) { if (gs->s) free(gs->s); gs->s = NULL; gs->len = 0; }

Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg35100.00%1100.00%
Total35100.00%1100.00%

/* Append to growable string */
void str_append(struct gstr *gs, const char *s) { size_t l; if (s) { l = strlen(gs->s) + strlen(s) + 1; if (l > gs->len) { gs->s = xrealloc(gs->s, l); gs->len = l; } strcat(gs->s, s); } }

Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg7798.72%266.67%
Masahiro Yamada11.28%133.33%
Total78100.00%3100.00%

/* Append printf formatted string to growable string */
void str_printf(struct gstr *gs, const char *fmt, ...) { va_list ap; char s[10000]; /* big enough... */ va_start(ap, fmt); vsnprintf(s, sizeof(s), fmt, ap); str_append(gs, s); va_end(ap); }

Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg60100.00%1100.00%
Total60100.00%1100.00%

/* Retrieve value of growable string */
const char *str_get(struct gstr *gs) { return gs->s; }

Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg17100.00%1100.00%
Total17100.00%1100.00%


void *xmalloc(size_t size) { void *p = malloc(size); if (p) return p; fprintf(stderr, "Out of memory.\n"); exit(1); }

Contributors

PersonTokensPropCommitsCommitProp
Alan Cox37100.00%1100.00%
Total37100.00%1100.00%


void *xcalloc(size_t nmemb, size_t size) { void *p = calloc(nmemb, size); if (p) return p; fprintf(stderr, "Out of memory.\n"); exit(1); }

Contributors

PersonTokensPropCommitsCommitProp
Alan Cox42100.00%1100.00%
Total42100.00%1100.00%


void *xrealloc(void *p, size_t size) { p = realloc(p, size); if (p) return p; fprintf(stderr, "Out of memory.\n"); exit(1); }

Contributors

PersonTokensPropCommitsCommitProp
Masahiro Yamada41100.00%1100.00%
Total41100.00%1100.00%


char *xstrdup(const char *s) { char *p; p = strdup(s); if (p) return p; fprintf(stderr, "Out of memory.\n"); exit(1); }

Contributors

PersonTokensPropCommitsCommitProp
Masahiro Yamada41100.00%1100.00%
Total41100.00%1100.00%


char *xstrndup(const char *s, size_t n) { char *p; p = strndup(s, n); if (p) return p; fprintf(stderr, "Out of memory.\n"); exit(1); }

Contributors

PersonTokensPropCommitsCommitProp
Masahiro Yamada46100.00%1100.00%
Total46100.00%1100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Sam Ravnborg45064.19%316.67%
Masahiro Yamada13419.12%422.22%
Alan Cox8111.55%15.56%
Roman Zippel131.85%211.11%
Arnaud Lacombe81.14%316.67%
Vadim Bendebury60.86%15.56%
Markus Heidelberg60.86%15.56%
Matt Mackall10.14%15.56%
Thomas Weber10.14%15.56%
Christophe Jaillet10.14%15.56%
Total701100.00%18100.00%
Directory: scripts/kconfig
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.