Skip to content

Commit 5c74cd4

Browse files
committed
Merge branch 'kconfig-trivial' of git://github.com/lacombar/linux-2.6 into kbuild/kconfig
2 parents e54e692 + ab63f58 commit 5c74cd4

3 files changed

Lines changed: 39 additions & 22 deletions

File tree

‎scripts/kconfig/conf.c‎

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
static void conf(struct menu *menu);
2020
static void check_conf(struct menu *menu);
21+
static void xfgets(char *str, int size, FILE *in);
2122

2223
enum input_mode {
2324
oldaskconfig,
@@ -34,8 +35,6 @@ enum input_mode {
3435
oldnoconfig,
3536
} input_mode = oldaskconfig;
3637

37-
char *defconfig_file;
38-
3938
static int indent = 1;
4039
static int valid_stdin = 1;
4140
static int sync_kconfig;
@@ -459,10 +458,30 @@ static struct option long_opts[] = {
459458
{NULL, 0, NULL, 0}
460459
};
461460

461+
static void conf_usage(const char *progname)
462+
{
463+
464+
printf("Usage: %s [option] <kconfig-file>\n", progname);
465+
printf("[option] is _one_ of the following:\n");
466+
printf(" --listnewconfig List new options\n");
467+
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
468+
printf(" --oldconfig Update a configuration using a provided .config as base\n");
469+
printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
470+
printf(" --oldnoconfig Same as silentoldconfig but set new symbols to no\n");
471+
printf(" --defconfig <file> New config with default defined in <file>\n");
472+
printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
473+
printf(" --allnoconfig New config where all options are answered with no\n");
474+
printf(" --allyesconfig New config where all options are answered with yes\n");
475+
printf(" --allmodconfig New config where all options are answered with mod\n");
476+
printf(" --alldefconfig New config with all symbols set to default\n");
477+
printf(" --randconfig New config with random answer to all options\n");
478+
}
479+
462480
int main(int ac, char **av)
463481
{
482+
const char *progname = av[0];
464483
int opt;
465-
const char *name;
484+
const char *name, *defconfig_file = NULL /* gcc uninit */;
466485
struct stat tmpstat;
467486

468487
setlocale(LC_ALL, "");
@@ -494,14 +513,24 @@ int main(int ac, char **av)
494513
srand(seed);
495514
break;
496515
}
516+
case oldaskconfig:
517+
case oldconfig:
518+
case allnoconfig:
519+
case allyesconfig:
520+
case allmodconfig:
521+
case alldefconfig:
522+
case listnewconfig:
523+
case oldnoconfig:
524+
break;
497525
case '?':
498-
fprintf(stderr, _("See README for usage info\n"));
526+
conf_usage(progname);
499527
exit(1);
500528
break;
501529
}
502530
}
503531
if (ac == optind) {
504532
printf(_("%s: Kconfig file missing\n"), av[0]);
533+
conf_usage(progname);
505534
exit(1);
506535
}
507536
name = av[optind];
@@ -644,13 +673,11 @@ int main(int ac, char **av)
644673
}
645674
return 0;
646675
}
676+
647677
/*
648678
* Helper function to facilitate fgets() by Jean Sacren.
649679
*/
650-
void xfgets(str, size, in)
651-
char *str;
652-
int size;
653-
FILE *in;
680+
void xfgets(char *str, int size, FILE *in)
654681
{
655682
if (fgets(str, size, in) == NULL)
656683
fprintf(stderr, "\nError in reading or end of file.\n");

‎scripts/kconfig/expr.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,23 @@
1313

1414
struct expr *expr_alloc_symbol(struct symbol *sym)
1515
{
16-
struct expr *e = malloc(sizeof(*e));
17-
memset(e, 0, sizeof(*e));
16+
struct expr *e = calloc(1, sizeof(*e));
1817
e->type = E_SYMBOL;
1918
e->left.sym = sym;
2019
return e;
2120
}
2221

2322
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
2423
{
25-
struct expr *e = malloc(sizeof(*e));
26-
memset(e, 0, sizeof(*e));
24+
struct expr *e = calloc(1, sizeof(*e));
2725
e->type = type;
2826
e->left.expr = ce;
2927
return e;
3028
}
3129

3230
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
3331
{
34-
struct expr *e = malloc(sizeof(*e));
35-
memset(e, 0, sizeof(*e));
32+
struct expr *e = calloc(1, sizeof(*e));
3633
e->type = type;
3734
e->left.expr = e1;
3835
e->right.expr = e2;
@@ -41,8 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
4138

4239
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
4340
{
44-
struct expr *e = malloc(sizeof(*e));
45-
memset(e, 0, sizeof(*e));
41+
struct expr *e = calloc(1, sizeof(*e));
4642
e->type = type;
4743
e->left.sym = s1;
4844
e->right.sym = s2;

‎scripts/kconfig/lkc.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ void zconf_nextfile(const char *name);
7676
int zconf_lineno(void);
7777
const char *zconf_curname(void);
7878

79-
/* conf.c */
80-
void xfgets(char *str, int size, FILE *in);
81-
8279
/* confdata.c */
8380
const char *conf_get_configname(void);
8481
const char *conf_get_autoconfig_name(void);
@@ -99,9 +96,6 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
9996
fprintf(stderr, "\nError in writing or end of file.\n");
10097
}
10198

102-
/* kconfig_load.c */
103-
void kconfig_load(void);
104-
10599
/* menu.c */
106100
void _menu_init(void);
107101
void menu_warn(struct menu *menu, const char *fmt, ...);

0 commit comments

Comments
 (0)