Skip to contentSkip to conversation

kconfig: comparison feature between two .config files added to mconf

PATCH Superseded Franco Martelli 3 participants 9 messages Jun 1, 2025 – Jun 2, 2025

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover kconfig: comparison feature between two .config files added to mconf

Dear Linux hacker,

I've written a patch that allows to compare the tristate value of two .config files inline, symbol by symbol, in mconf (make menuconfig) only. It can be useful when customizing the .config file, personally I use it to compare my .config file with the one provided by the software distribution.

A screenshot of the new mconf view is available here:
https://i.is.cc/2cpIXxoP.jpg

The patch was originally written on Linux 6.1 amd64 series tested on 6.1.137 kernel version.

The patch has a limitation, it only show the tristate value (Y/N/M) not differences for symbol with a value (string), but it also marks with a "#" the symbol missing in the loaded .config, meaning therefore the symbol as a new feature.

o I've also added support for the more canonical <F1> key to show inline help window, in addition to <?> and <h> keys.

o By pressing the <F2> key you will get a view with all the symbol differences listed.

o By pressing the <F4> key you'll save to a file the differences.

o Added help text that it describes the new features.

If you like this patch, it would be nice that other kconfig GUI client such as nconf, gconf and qconf be patched in order to have compare capability for them too.
This software is under GPL-2.0 license.

Franco Martelli (1):
Kconfig: Added compare capabilities for mconf

 scripts/kconfig/confdata.c         | 165 ++++++++++++++++++++++++-
 scripts/kconfig/expr.h             |   9 ++
 scripts/kconfig/lkc.h              |  11 ++
 scripts/kconfig/lkc_proto.h        |   4 +
 scripts/kconfig/lxdialog/menubox.c |  13 +-
 scripts/kconfig/mconf.c            | 192 ++++++++++++++++++++++++++---
 6 files changed, 376 insertions(+), 18 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/1 Kconfig: Added compare capabilities for mconf

---
 scripts/kconfig/confdata.c         | 165 ++++++++++++++++++++++++-
 scripts/kconfig/expr.h             |   9 ++
 scripts/kconfig/lkc.h              |  11 ++
 scripts/kconfig/lkc_proto.h        |   4 +
 scripts/kconfig/lxdialog/menubox.c |  13 +-
 scripts/kconfig/mconf.c            | 192 ++++++++++++++++++++++++++---
 6 files changed, 376 insertions(+), 18 deletions(-)
scripts/kconfig/confdata.c +164 -1
index ac95661a1c9d..078d058c01d7 100644
@@ -257,7 +257,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
 			sym->flags |= def_flags;
 			break;
 		}
-		if (def != S_DEF_AUTO)
+		if (def != S_DEF_AUTO && def != S_DEF_COMP)
 			conf_warning("symbol value '%s' invalid for %s",
 				     p, sym->name);
 		return 1;
@@ -386,6 +386,7 @@ int conf_read_simple(const char *name, int def)
 	def_flags = SYMBOL_DEF << def;
 	for_all_symbols(sym) {
 		sym->flags &= ~def_flags;
+		sym->comp_is_avail = false;
 		switch (sym->type) {
 		case S_INT:
 		case S_HEX:
@@ -445,6 +446,8 @@ int conf_read_simple(const char *name, int def)
 
 		sym = sym_find(sym_name);
 		if (!sym) {
+			if (def == S_DEF_COMP)
+				continue;
 			if (def == S_DEF_AUTO) {
 				/*
 				 * Reading from include/config/auto.conf.
@@ -462,6 +465,9 @@ int conf_read_simple(const char *name, int def)
 			continue;
 		}
 
+		if (def == S_DEF_COMP)
+			sym->comp_is_avail = true;
+
 		if (sym->flags & def_flags)
 			conf_warning("override: reassigning to symbol %s", sym->name);
 
@@ -529,6 +535,91 @@ int conf_read(const char *name)
 	return 0;
 }
 
+const char sym_get_comp_tristate_char(struct symbol *sym)
+{
+	char ch = '#';
+
+	if (sym_get_comp_is_avail(sym))
+		switch (sym_get_comp_tristate_value(sym)) {
+		case yes: ch = '*'; break;
+		case mod: ch = 'M'; break;
+		case no:  ch = '_'; break;
+		}
+
+	return ch;
+}
+
+static char * masked_xrealloc(char *s, size_t len, size_t *size)
+{
+	char *ls = s;
+
+	if (s == NULL)
+		*size = 0;
+	if (len > *size)
+		ls = xrealloc(s, (*size = ((len / SYMBOL_MAXLENGTH) + 1) * SYMBOL_MAXLENGTH));
+
+	return ls;
+}
+
+#define LINE_LENGTH	(SYMBOL_MAXLENGTH +32)
+
+char * comp_get_list_diff(void)
+{
+	char *line, *l_rst, *list = NULL, ch_comp;
+	size_t idx = 0, szs;
+	struct symbol *sym;
+	tristate tri_val, tri_comp_val;
+
+	l_rst = line = xmalloc(LINE_LENGTH);
+
+	for_all_symbols(sym) {
+		if (!sym->name)
+			continue;
+		tri_val = sym_get_tristate_value(sym);
+		tri_comp_val = sym_get_comp_tristate_value(sym);
+
+		if (tri_val != tri_comp_val) {
+			ch_comp = sym_get_comp_tristate_char(sym);
+			switch (tri_val) {
+			case yes:
+				snprintf(line, LINE_LENGTH, "%s%s=y --- %c\n", CONFIG_, sym->name, ch_comp);
+				break;
+			case mod:
+				snprintf(line, LINE_LENGTH, "%s%s=m --- %c\n", CONFIG_, sym->name, ch_comp);
+				break;
+			case no:
+				snprintf(line, LINE_LENGTH, "# %s%s is not set --- %c\n",
+					 CONFIG_, sym->name, ch_comp);
+				break;
+			}
+
+			for (; *line; ++idx) {
+				list = masked_xrealloc(list, idx + 2, &szs);
+				list[idx] = *line++;
+			}
+			line = l_rst;
+		}
+	}
+	free(line);
+
+	if (list)
+		list[idx] = '\0';
+	else {
+		list = xmalloc(32);
+		strcpy(list, "No differences found.");
+	}
+
+	return list;
+}
+
+int conf_read_comp(const char *name)
+{
+	if (conf_read_simple(name, S_DEF_COMP))
+		return 1;
+
+	return 0;
+}
+
 struct comment_style {
 	const char *decoration;
 	const char *prefix;
@@ -801,6 +892,78 @@ int conf_write_defconfig(const char *filename)
 	return 0;
 }
 
+bool conf_write_comp(const char *name)
+{
+	FILE *fptemp, *fplist;
+	char *list = NULL, f_old[PATH_MAX +1],  tmpfile[] = "file_XXXXXX";
+	int ch;
+
+	if (!name)
+		return false;
+
+	if (is_present(name)) {
+		if (is_dir(name))
+			return false;
+		snprintf(f_old, PATH_MAX, "%s.old", name);
+		if (rename(name, f_old)) {
+			fprintf(stderr, "Failed to rename file: %s to %s\n", name, f_old);
+			return false;
+		}
+	}
+
+	list = comp_get_list_diff();
+	int tmpfd = mkstemp(tmpfile);
+
+	if (tmpfd < 0) {
+		fprintf( stderr, "Failed to create temporary file.\n" );
+		return false;
+	}
+
+	if ((fptemp = fdopen(tmpfd, "w")) == NULL) {
+		remove(tmpfile);
+		fprintf(stderr, "Failed to open a stream for the temporary file: %s\n", tmpfile);
+		return false;
+	}
+
+	if ((fplist = fmemopen(list, strlen(list), "r")) == NULL ) {
+		fclose(fptemp);
+		remove(tmpfile);
+		fprintf( stderr, "Failed to open a stream for fplist.\n" );
+		if (list)
+			free(list);
+		return false;
+	}
+
+	while ((ch = fgetc(fplist)) != EOF)
+		fputc(ch, fptemp);
+
+	if (ferror(fptemp)) {	/* checks whether fputc has encountered errors while writing the file */
+		fclose(fptemp);
+		fclose(fplist);
+		if (list)
+			free(list);
+		fprintf( stderr, "An error occured when writing the file: %s", tmpfile);
+		return false;
+	}
+
+	if (rename(tmpfile, name)) {
+		fprintf(stderr, "Failed to rename file: %s to %s\n", tmpfile, name);
+		fclose(fptemp);
+		fclose(fplist);
+		if (list)
+			free(list);
+		remove(tmpfile);
+		return false;
+	}
+
+	fclose(fptemp);
+	fclose(fplist);
+	if (list)
+		free(list);
+
+	return true;
+}
+
 int conf_write(const char *name)
 {
 	FILE *out;
scripts/kconfig/expr.h +9 -0
index 21578dcd4292..89b5d1cde63d 100644
@@ -76,6 +76,7 @@ enum {
 	S_DEF_AUTO,		/* values read from auto.conf */
 	S_DEF_DEF3,		/* Reserved for UI usage */
 	S_DEF_DEF4,		/* Reserved for UI usage */
+	S_DEF_COMP,		/* values for comparison purposes */
 	S_DEF_COUNT
 };
 
@@ -140,6 +141,13 @@ struct symbol {
 	 * "Weak" reverse dependencies through being implied by other symbols
 	 */
 	struct expr_value implied;
+
+	/*
+	 * Used by comparison code. "true" when the symbol is present in the compared
+	 * .config, "false" if it's missing in the compared .config, meaning
+	 * therefore a new feature.
+	 */
+	bool comp_is_avail;
 };
 
 #define SYMBOL_CONST      0x0001  /* symbol is const */
@@ -156,6 +164,7 @@ struct symbol {
 #define SYMBOL_DEF_AUTO   0x20000  /* symbol.def[S_DEF_AUTO] is valid */
 #define SYMBOL_DEF3       0x40000  /* symbol.def[S_DEF_3] is valid */
 #define SYMBOL_DEF4       0x80000  /* symbol.def[S_DEF_4] is valid */
+#define SYMBOL_DEF_COMP	  0x100000 /* symbol.def[S_DEF_COMP] is valid */
 
 #define SYMBOL_MAXLENGTH	256
 
scripts/kconfig/lkc.h +11 -0
index b8ebc3094a23..0ddf142ec7e8 100644
@@ -9,6 +9,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 
 #include "expr.h"
 
@@ -129,6 +130,16 @@ static inline bool sym_has_value(const struct symbol *sym)
 	return sym->flags & SYMBOL_DEF_USER ? true : false;
 }
 
+static inline bool sym_get_comp_is_avail(struct symbol *sym)
+{
+	return sym->comp_is_avail;
+}
+
+static inline tristate sym_get_comp_tristate_value(struct symbol *sym)
+{
+	return sym->def[S_DEF_COMP].tri;
+}
+
 #ifdef __cplusplus
 }
 #endif
scripts/kconfig/lkc_proto.h +4 -0
index 8914b4e8f2a8..0f71786b4245 100644
@@ -7,6 +7,10 @@
 /* confdata.c */
 void conf_parse(const char *name);
 int conf_read(const char *name);
+int conf_read_comp(const char *name);
+bool conf_write_comp(const char *name);
+const char sym_get_comp_tristate_char(struct symbol *sym);
+char * comp_get_list_diff(void);
 int conf_read_simple(const char *name, int);
 int conf_write_defconfig(const char *name);
 int conf_write(const char *name);
scripts/kconfig/lxdialog/menubox.c +11 -2
index 6e6244df0c56..11e92da37e9f 100644
@@ -141,6 +141,7 @@ static void print_buttons(WINDOW * win, int height, int width, int selected)
 	print_button(win, " Help ", y, x + 24, selected == 2);
 	print_button(win, " Save ", y, x + 36, selected == 3);
 	print_button(win, " Load ", y, x + 48, selected == 4);
+	print_button(win, "Compare", y, x + 60, selected == 5);
 
 	wmove(win, y, x + 1 + 12 * selected);
 	wrefresh(win);
@@ -354,11 +355,14 @@ int dialog_menu(const char *title, const char *prompt,
 		case TAB:
 		case KEY_RIGHT:
 			button = ((key == KEY_LEFT ? --button : ++button) < 0)
-			    ? 4 : (button > 4 ? 0 : button);
+			    ? 5 : (button > 5 ? 0 : button);
 
 			print_buttons(dialog, height, width, button);
 			wrefresh(menu);
 			break;
+		case KEY_F(1):
+		case KEY_F(2):
+		case KEY_F(4):
 		case ' ':
 		case 's':
 		case 'y':
@@ -376,6 +380,7 @@ int dialog_menu(const char *title, const char *prompt,
 			item_set(scroll + choice);
 			item_set_selected(1);
 			switch (key) {
+			case KEY_F(1):
 			case 'h':
 			case '?':
 				return 2;
@@ -392,8 +397,12 @@ int dialog_menu(const char *title, const char *prompt,
 				return 9;
 			case 'z':
 				return 10;
+			case KEY_F(2):		/* Differences between .config files view */
+				return 40;
+			case KEY_F(4):		/* Save to file differences between .config files */
+				return 60;
 			case '\n':
-				return button;
+				return button == 5 ? 50 : button;	/* Workaround for Compare button */
 			}
 			return 0;
 		case 'e':
scripts/kconfig/mconf.c +177 -15

273 lines not on this page · raw message

Signature · 1 line
2.39.5
#2 lore raw

Re: [PATCH 1/1] Kconfig: Added compare capabilities for mconf

On 6/1/25 11:40 AM, Franco Martelli wrote:

Missing patch description/justification here.....

Quoted 59 lines
---
 scripts/kconfig/confdata.c         | 165 ++++++++++++++++++++++++-
 scripts/kconfig/expr.h             |   9 ++
 scripts/kconfig/lkc.h              |  11 ++
 scripts/kconfig/lkc_proto.h        |   4 +
 scripts/kconfig/lxdialog/menubox.c |  13 +-
 scripts/kconfig/mconf.c            | 192 ++++++++++++++++++++++++++---
 6 files changed, 376 insertions(+), 18 deletions(-)
scripts/kconfig/confdata.c +12 -1
index ac95661a1c9d..078d058c01d7 100644
@@ -257,7 +257,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
 			sym->flags |= def_flags;
 			break;
 		}
-		if (def != S_DEF_AUTO)
+		if (def != S_DEF_AUTO && def != S_DEF_COMP)
 			conf_warning("symbol value '%s' invalid for %s",
 				     p, sym->name);
 		return 1;
@@ -386,6 +386,7 @@ int conf_read_simple(const char *name, int def)
 	def_flags = SYMBOL_DEF << def;
 	for_all_symbols(sym) {
 		sym->flags &= ~def_flags;
+		sym->comp_is_avail = false;
 		switch (sym->type) {
 		case S_INT:
 		case S_HEX:
@@ -445,6 +446,8 @@ int conf_read_simple(const char *name, int def)
 
 		sym = sym_find(sym_name);
 		if (!sym) {
+			if (def == S_DEF_COMP)
+				continue;
 			if (def == S_DEF_AUTO) {
 				/*
 				 * Reading from include/config/auto.conf.
@@ -462,6 +465,9 @@ int conf_read_simple(const char *name, int def)
 			continue;
 		}
 
+		if (def == S_DEF_COMP)
+			sym->comp_is_avail = true;
+
 		if (sym->flags & def_flags)
 			conf_warning("override: reassigning to symbol %s", sym->name);
 
@@ -529,6 +535,91 @@ int conf_read(const char *name)
 	return 0;
 }
 
+const char sym_get_comp_tristate_char(struct symbol *sym)
+{
+	char ch = '#';
+
+	if (sym_get_comp_is_avail(sym))

scripts/kconfig/confdata.c int conf_read(const char *name) · line 552

Quoted 10 lines
scripts/kconfig/confdata.c +10 -0
+		switch (sym_get_comp_tristate_value(sym)) {
+		case yes: ch = '*'; break;
+		case mod: ch = 'M'; break;
+		case no:  ch = '_'; break;
+		}
+
+	return ch;
+}
+
+static char * masked_xrealloc(char *s, size_t len, size_t *size)

static char *mask_xrealloc(...
(no space after '*')

Quoted 4 lines
scripts/kconfig/confdata.c +4 -0
+{
+	char *ls = s;
+
+	if (s == NULL)

scripts/kconfig/confdata.c int conf_read(const char *name) · line 566

Quoted 10 lines
scripts/kconfig/confdata.c +10 -0
+		*size = 0;
+	if (len > *size)
+		ls = xrealloc(s, (*size = ((len / SYMBOL_MAXLENGTH) + 1) * SYMBOL_MAXLENGTH));
+
+	return ls;
+}
+
+#define LINE_LENGTH	(SYMBOL_MAXLENGTH +32)
+
+char * comp_get_list_diff(void)

ditto.

Quoted 49 lines
scripts/kconfig/confdata.c +43 -0
+{
 
+}
 
@@ -801,6 +892,78 @@ int conf_write_defconfig(const char *filename)
 	return 0;
 }
 
+bool conf_write_comp(const char *name)
+{
+	FILE *fptemp, *fplist;
+	char *list = NULL, f_old[PATH_MAX +1],  tmpfile[] = "file_XXXXXX";
+	int ch;
+
+	if (!name)
+		return false;
+
+	if (is_present(name)) {
+		if (is_dir(name))
+			return false;
+		snprintf(f_old, PATH_MAX, "%s.old", name);
+		if (rename(name, f_old)) {
+			fprintf(stderr, "Failed to rename file: %s to %s\n", name, f_old);
+			return false;
+		}
+	}
+
+	list = comp_get_list_diff();
+	int tmpfd = mkstemp(tmpfile);
+
+	if (tmpfd < 0) {
+		fprintf( stderr, "Failed to create temporary file.\n" );
+		return false;
+	}
+
+	if ((fptemp = fdopen(tmpfd, "w")) == NULL) {
+		remove(tmpfile);
+		fprintf(stderr, "Failed to open a stream for the temporary file: %s\n", tmpfile);
+		return false;
+	}
+
+	if ((fplist = fmemopen(list, strlen(list), "r")) == NULL ) {
+		fclose(fptemp);
+		remove(tmpfile);
+		fprintf( stderr, "Failed to open a stream for fplist.\n" );
+		if (list)
+			free(list);
+		return false;
+	}

scripts/kconfig/confdata.c int conf_write_defconfig(const char *filename) · line 945

Quoted 10 lines
scripts/kconfig/confdata.c +10 -0
+
+	while ((ch = fgetc(fplist)) != EOF)
+		fputc(ch, fptemp);
+
+	if (ferror(fptemp)) {	/* checks whether fputc has encountered errors while writing the file */
+		fclose(fptemp);
+		fclose(fplist);
+		if (list)
+			free(list);
+		fprintf( stderr, "An error occured when writing the file: %s", tmpfile);

occurred

Quoted 24 lines
scripts/kconfig/confdata.c +21 -0
+		return false;
+	}
+
+	if (rename(tmpfile, name)) {
+		fprintf(stderr, "Failed to rename file: %s to %s\n", tmpfile, name);
+		fclose(fptemp);
+		fclose(fplist);
+		if (list)
+			free(list);
+		remove(tmpfile);
+		return false;
+	}
+
+	fclose(fptemp);
+	fclose(fplist);
+	if (list)
+		free(list);
+
+	return true;
+}
+
 int conf_write(const char *name)
 {
 	FILE *out;
Signature · 1 line
~Randy
#3 lore raw

Re: [PATCH 1/1] Kconfig: Added compare capabilities for mconf

Quoted 5 lines · Randy Dunlap

On 6/1/25 11:40 AM, Franco Martelli wrote:

Missing patch description/justification here.....

Have you run a specific "git" command or simply edited the patch body before sending?

Quoted 170 lines
Quoted 61 lines
---
  scripts/kconfig/confdata.c         | 165 ++++++++++++++++++++++++-
  scripts/kconfig/expr.h             |   9 ++
  scripts/kconfig/lkc.h              |  11 ++
  scripts/kconfig/lkc_proto.h        |   4 +
  scripts/kconfig/lxdialog/menubox.c |  13 +-
  scripts/kconfig/mconf.c            | 192 ++++++++++++++++++++++++++---
  6 files changed, 376 insertions(+), 18 deletions(-)
scripts/kconfig/confdata.c +12 -1
index ac95661a1c9d..078d058c01d7 100644
@@ -257,7 +257,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
  			sym->flags |= def_flags;
  			break;
  		}
-		if (def != S_DEF_AUTO)
+		if (def != S_DEF_AUTO && def != S_DEF_COMP)
  			conf_warning("symbol value '%s' invalid for %s",
  				     p, sym->name);
  		return 1;
@@ -386,6 +386,7 @@ int conf_read_simple(const char *name, int def)
  	def_flags = SYMBOL_DEF << def;
  	for_all_symbols(sym) {
  		sym->flags &= ~def_flags;
+		sym->comp_is_avail = false;
  		switch (sym->type) {
  		case S_INT:
  		case S_HEX:
@@ -445,6 +446,8 @@ int conf_read_simple(const char *name, int def)
 
  		sym = sym_find(sym_name);
  		if (!sym) {
+			if (def == S_DEF_COMP)
+				continue;
  			if (def == S_DEF_AUTO) {
  				/*
  				 * Reading from include/config/auto.conf.
@@ -462,6 +465,9 @@ int conf_read_simple(const char *name, int def)
  			continue;
  		}
 
+		if (def == S_DEF_COMP)
+			sym->comp_is_avail = true;
+
  		if (sym->flags & def_flags)
  			conf_warning("override: reassigning to symbol %s", sym->name);
 
@@ -529,6 +535,91 @@ int conf_read(const char *name)
  	return 0;
  }
 
+const char sym_get_comp_tristate_char(struct symbol *sym)
+{
+	char ch = '#';
+
+	if (sym_get_comp_is_avail(sym))

scripts/kconfig/confdata.c int conf_read(const char *name) · line 552

Quoted 10 lines
scripts/kconfig/confdata.c +10 -0
+		switch (sym_get_comp_tristate_value(sym)) {
+		case yes: ch = '*'; break;
+		case mod: ch = 'M'; break;
+		case no:  ch = '_'; break;
+		}
+
+	return ch;
+}
+
+static char * masked_xrealloc(char *s, size_t len, size_t *size)

static char *mask_xrealloc(...
(no space after '*')

Quoted 4 lines
scripts/kconfig/confdata.c +4 -0
+{
+	char *ls = s;
+
+	if (s == NULL)

scripts/kconfig/confdata.c int conf_read(const char *name) · line 566

Quoted 10 lines
scripts/kconfig/confdata.c +10 -0
+		*size = 0;
+	if (len > *size)
+		ls = xrealloc(s, (*size = ((len / SYMBOL_MAXLENGTH) + 1) * SYMBOL_MAXLENGTH));
+
+	return ls;
+}
+
+#define LINE_LENGTH	(SYMBOL_MAXLENGTH +32)
+
+char * comp_get_list_diff(void)

ditto.

Quoted 49 lines
scripts/kconfig/confdata.c +43 -0
+{
 
+}
 
@@ -801,6 +892,78 @@ int conf_write_defconfig(const char *filename)
  	return 0;
  }
 
+bool conf_write_comp(const char *name)
+{
+	FILE *fptemp, *fplist;
+	char *list = NULL, f_old[PATH_MAX +1],  tmpfile[] = "file_XXXXXX";
+	int ch;
+
+	if (!name)
+		return false;
+
+	if (is_present(name)) {
+		if (is_dir(name))
+			return false;
+		snprintf(f_old, PATH_MAX, "%s.old", name);
+		if (rename(name, f_old)) {
+			fprintf(stderr, "Failed to rename file: %s to %s\n", name, f_old);
+			return false;
+		}
+	}
+
+	list = comp_get_list_diff();
+	int tmpfd = mkstemp(tmpfile);
+
+	if (tmpfd < 0) {
+		fprintf( stderr, "Failed to create temporary file.\n" );
+		return false;
+	}
+
+	if ((fptemp = fdopen(tmpfd, "w")) == NULL) {
+		remove(tmpfile);
+		fprintf(stderr, "Failed to open a stream for the temporary file: %s\n", tmpfile);
+		return false;
+	}
+
+	if ((fplist = fmemopen(list, strlen(list), "r")) == NULL ) {
+		fclose(fptemp);
+		remove(tmpfile);
+		fprintf( stderr, "Failed to open a stream for fplist.\n" );
+		if (list)
+			free(list);
+		return false;
+	}

scripts/kconfig/confdata.c int conf_write_defconfig(const char *filename) · line 945

Quoted 10 lines
scripts/kconfig/confdata.c +10 -0
+
+	while ((ch = fgetc(fplist)) != EOF)
+		fputc(ch, fptemp);
+
+	if (ferror(fptemp)) {	/* checks whether fputc has encountered errors while writing the file */
+		fclose(fptemp);
+		fclose(fplist);
+		if (list)
+			free(list);
+		fprintf( stderr, "An error occured when writing the file: %s", tmpfile);

occurred

Quoted 16 lines
scripts/kconfig/confdata.c +16 -0
+		return false;
+	}
+
+	if (rename(tmpfile, name)) {
+		fprintf(stderr, "Failed to rename file: %s to %s\n", tmpfile, name);
+		fclose(fptemp);
+		fclose(fplist);
+		if (list)
+			free(list);
+		remove(tmpfile);
+		return false;
+	}
+
+	fclose(fptemp);
+	fclose(fplist);
+	if (list)
Quoted 10 lines

scripts/kconfig/confdata.c int conf_write_defconfig(const char *filename) · line 969

Quoted 8 lines
scripts/kconfig/confdata.c +5 -0
+		free(list);
+
+	return true;
+}
+
  int conf_write(const char *name)
  {
  	FILE *out;

Sadly I forgot to run ./scripts/checkpatch.pl before sending the patch, sorry, my mistake.
Now how to deal with those typos? Should I git amend the commit and send a new version 2 of the patch? Sorry but I'm new in the kernel's process patching.

Signature · 1 line
Franco Martelli
#4 lore raw

Re: [PATCH 1/1] Kconfig: Added compare capabilities for mconf

Quoted 4 lines · Franco Martelli

Now how to deal with those typos? Should I git amend the commit and send a new version 2 of the patch? Sorry but I'm new in the kernel's process patching.

Yeah, you should amend it and send a new version, tagged with v2 with e.g. the -v2 flag or similar. In other words, new versions should not depend on the previous ones -- patch series are "rebased" in that sense, rather than "stacked".

For new versions, you should also provide a changelog, after the first --- line, before the diffstat.

By the way, ideally you also pass format-patch the --base flag to provide a base commit for all patch series, so that it is clearer for both humans and tooling :)

Thanks!

Cheers,
Miguel

#5 lore raw

Re: [PATCH 1/1] Kconfig: Added compare capabilities for mconf

In reply to Franco Martelli
Quoted 9 lines · Franco Martelli
Quoted 5 lines · Randy Dunlap

On 6/1/25 11:40 AM, Franco Martelli wrote:

Missing patch description/justification here.....

Have you run a specific "git" command or simply edited the patch body before sending?

I just edited the patch body.

Signature · 1 line
~Randy
#6 lore raw
In reply to Franco Martelli

Hi,

Quoted 7 lines · Franco Martelli

Dear Linux hacker,

I've written a patch that allows to compare the tristate value of two .config files inline, symbol by symbol, in mconf (make menuconfig) only. It can be useful when customizing the .config file, personally I use it to compare my .config file with the one provided by the software distribution.

I like this concept. Thanks.

Quoted 2 lines
Quoted 1 line

A screenshot of the new mconf view is available here:

https://i.is.cc/2cpIXxoP.jpg

That virtual terminal is wider than 80 columns. :)

Please make <Compare> fit into an 80-columns terminal (squeeze spaces on that line).

Quoted 8 lines

The patch was originally written on Linux 6.1 amd64 series tested on 6.1.137 kernel version.

The patch has a limitation, it only show the tristate value (Y/N/M) not differences for symbol with a value (string), but it also marks with a "#" the symbol missing in the loaded .config, meaning therefore the symbol as a new feature.

Quoted 7 lines

o I've also added support for the more canonical <F1> key to show inline help window, in addition to <?> and <h> keys.

o By pressing the <F2> key you will get a view with all the symbol differences listed.

o By pressing the <F4> key you'll save to a file the differences.

I would appreciate at least one alternate to F2 (Compare) and F4 (save diff to file) since my window manager (xfce4) intercepts Function keys.

Quoted 10 lines

o Added help text that it describes the new features.

If you like this patch, it would be nice that other kconfig GUI client such as nconf, gconf and qconf be patched in order to have compare capability for them too.
This software is under GPL-2.0 license.

Franco Martelli (1):
Kconfig: Added compare capabilities for mconf

Quoted 8 lines
 scripts/kconfig/confdata.c         | 165 ++++++++++++++++++++++++-
 scripts/kconfig/expr.h             |   9 ++
 scripts/kconfig/lkc.h              |  11 ++
 scripts/kconfig/lkc_proto.h        |   4 +
 scripts/kconfig/lxdialog/menubox.c |  13 +-
 scripts/kconfig/mconf.c            | 192 ++++++++++++++++++++++++++---
 6 files changed, 376 insertions(+), 18 deletions(-)

The patch justification should be with patch 1/1, not patch 0/1, so that the maintainer does not need to merge text from 2 patches.

Signature · 1 line
~Randy
#7 lore raw

Hi,

Quoted 7 lines · Randy Dunlap

Hi,

Quoted 2 lines · Franco Martelli

Dear Linux hacker,

Quoted 7 lines
Quoted 5 lines

I've written a patch that allows to compare the tristate value of two .config files inline, symbol by symbol, in mconf (make menuconfig) only. It can be useful when customizing the .config file, personally I use it to compare my .config file with the one provided by the software distribution.

I like this concept. Thanks.

Of course there is also scripts/diffconfig but it can be a bit noisy.

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

A screenshot of the new mconf view is available here:

https://i.is.cc/2cpIXxoP.jpg

That virtual terminal is wider than 80 columns. :)

Please make <Compare> fit into an 80-columns terminal (squeeze spaces on that line).

See patch below.

Quoted 11 lines
Quoted 11 lines

The patch was originally written on Linux 6.1 amd64 series tested on 6.1.137 kernel version.

The patch has a limitation, it only show the tristate value (Y/N/M) not differences for symbol with a value (string), but it also marks with a "#" the symbol missing in the loaded .config, meaning therefore the symbol as a new feature.

o I've also added support for the more canonical <F1> key to show inline help window, in addition to <?> and <h> keys.

Quoted 8 lines
Quoted 4 lines

o By pressing the <F2> key you will get a view with all the symbol differences listed.

o By pressing the <F4> key you'll save to a file the differences.

I would appreciate at least one alternate to F2 (Compare) and F4 (save diff to file) since my window manager (xfce4) intercepts Function keys.

See patch below. You may use it if you care to.

Quoted 10 lines
Quoted 10 lines

o Added help text that it describes the new features.

If you like this patch, it would be nice that other kconfig GUI client such as nconf, gconf and qconf be patched in order to have compare capability for them too.
This software is under GPL-2.0 license.

Franco Martelli (1):
Kconfig: Added compare capabilities for mconf

Quoted 7 lines
Quoted 7 lines
 scripts/kconfig/confdata.c         | 165 ++++++++++++++++++++++++-
 scripts/kconfig/expr.h             |   9 ++
 scripts/kconfig/lkc.h              |  11 ++
 scripts/kconfig/lkc_proto.h        |   4 +
 scripts/kconfig/lxdialog/menubox.c |  13 +-
 scripts/kconfig/mconf.c            | 192 ++++++++++++++++++++++++++---
 6 files changed, 376 insertions(+), 18 deletions(-)

---

Adjust the locations of the menuconfig commands so that the new "Compare" command fits inside an 80-column-wide terminal.

Add shortcuts for the new F2 (add 'D') and F4 (add 'F') keys in case function keys are intercepted by some other software layer.

---
 scripts/kconfig/lxdialog/menubox.c |   16 ++++++++++------
 scripts/kconfig/mconf.c            |    4 ++--
 2 files changed, 12 insertions(+), 8 deletions(-)
scripts/kconfig/lxdialog/menubox.c +10 -6
@@ -133,15 +133,15 @@ static void print_arrows(WINDOW * win, i
  */
 static void print_buttons(WINDOW * win, int height, int width, int selected)
 {
-	int x = width / 2 - 28;
+	int x = width / 2 - 30;
 	int y = height - 2;
 
 	print_button(win, "Select", y, x, selected == 0);
-	print_button(win, " Exit ", y, x + 12, selected == 1);
-	print_button(win, " Help ", y, x + 24, selected == 2);
-	print_button(win, " Save ", y, x + 36, selected == 3);
-	print_button(win, " Load ", y, x + 48, selected == 4);
-	print_button(win, "Compare", y, x + 60, selected == 5);
+	print_button(win, " Exit ", y, x + 10, selected == 1);
+	print_button(win, " Help ", y, x + 20, selected == 2);
+	print_button(win, " Save ", y, x + 30, selected == 3);
+	print_button(win, " Load ", y, x + 40, selected == 4);
+	print_button(win, "Compare", y, x + 50, selected == 5);
 
 	wmove(win, y, x + 1 + 12 * selected);
 	wrefresh(win);
@@ -366,6 +366,8 @@ do_resize:
 		case ' ':
 		case 's':
 		case 'y':
+		case 'd':
+		case 'f':
 		case 'n':
 		case 'm':
 		case '/':
@@ -398,8 +400,10 @@ do_resize:
 			case 'z':
 				return 10;
 			case KEY_F(2):		/* Differences between .config files view */
+			case 'd':
 				return 40;
 			case KEY_F(4):		/* Save to file differences between .config files */
+			case 'f':
 				return 60;
 			case '\n':
 				return button == 5 ? 50 : button;	/* Workaround for Compare button */
scripts/kconfig/mconf.c +2 -2
@@ -137,9 +137,9 @@ static const char mconf_readme[] =
 "built-in, _: for a symbol excluded, M: for a symbol as module and #: for\n"
 "a symbol absent in the loaded \".config\" file, meaning therefore a new feature.\n"
 "\n"
-"Once loaded the .config file to compare, using the <F2> key a view will\n"
+"Once loaded the .config file to compare, using the <F2> or 'D' key a view will\n"
 "be displayed listing the differences between the two .config files, using\n"
-"the <F4> key instead, you can save to a file these differences.\n"
+"the <F4> or 'F' key instead, you can save to a file these differences.\n"
 "\n"
 "Other information\n"
 "-----------------\n"
Signature · 1 line
~Randy
#8 lore raw
Quoted 16 lines · Randy Dunlap

Hi,

Quoted 13 lines · Randy Dunlap

Hi,

Quoted 7 lines · Franco Martelli

Dear Linux hacker,

I've written a patch that allows to compare the tristate value of two .config files inline, symbol by symbol, in mconf (make menuconfig) only. It can be useful when customizing the .config file, personally I use it to compare my .config file with the one provided by the software distribution.

Quoted 3 lines
Quoted 1 line

I like this concept. Thanks.

Of course there is also scripts/diffconfig but it can be a bit noisy.

Yes, on the Internet there are many recipes to obtain differences between two files, but I would be liked something more direct.

Quoted 10 lines
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

A screenshot of the new mconf view is available here:

https://i.is.cc/2cpIXxoP.jpg

That virtual terminal is wider than 80 columns. :)

Please make <Compare> fit into an 80-columns terminal (squeeze spaces on that line).

See patch below.

Thanks for appreciate my patch! :)

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

The patch was originally written on Linux 6.1 amd64 series tested on 6.1.137 kernel version.

The patch has a limitation, it only show the tristate value (Y/N/M) not differences for symbol with a value (string), but it also marks with a "#" the symbol missing in the loaded .config, meaning therefore the symbol as a new feature.

o I've also added support for the more canonical <F1> key to show inline help window, in addition to <?> and <h> keys.

o By pressing the <F2> key you will get a view with all the symbol differences listed.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

o By pressing the <F4> key you'll save to a file the differences.

I would appreciate at least one alternate to F2 (Compare) and F4 (save diff to file) since my window manager (xfce4) intercepts Function keys.

See patch below. You may use it if you care to.

I'll apply surely, thanks again!

Quoted 93 lines
Quoted 10 lines
Quoted 10 lines

o Added help text that it describes the new features.

If you like this patch, it would be nice that other kconfig GUI client such as nconf, gconf and qconf be patched in order to have compare capability for them too.
This software is under GPL-2.0 license.

Franco Martelli (1):
Kconfig: Added compare capabilities for mconf

Quoted 7 lines
Quoted 7 lines
  scripts/kconfig/confdata.c         | 165 ++++++++++++++++++++++++-
  scripts/kconfig/expr.h             |   9 ++
  scripts/kconfig/lkc.h              |  11 ++
  scripts/kconfig/lkc_proto.h        |   4 +
  scripts/kconfig/lxdialog/menubox.c |  13 +-
  scripts/kconfig/mconf.c            | 192 ++++++++++++++++++++++++++---
  6 files changed, 376 insertions(+), 18 deletions(-)

---

Adjust the locations of the menuconfig commands so that the new "Compare" command fits inside an 80-column-wide terminal.

Add shortcuts for the new F2 (add 'D') and F4 (add 'F') keys in case function keys are intercepted by some other software layer.

---
  scripts/kconfig/lxdialog/menubox.c |   16 ++++++++++------
  scripts/kconfig/mconf.c            |    4 ++--
  2 files changed, 12 insertions(+), 8 deletions(-)
scripts/kconfig/lxdialog/menubox.c +10 -6
@@ -133,15 +133,15 @@ static void print_arrows(WINDOW * win, i
   */
  static void print_buttons(WINDOW * win, int height, int width, int selected)
  {
-	int x = width / 2 - 28;
+	int x = width / 2 - 30;
  	int y = height - 2;
 
  	print_button(win, "Select", y, x, selected == 0);
-	print_button(win, " Exit ", y, x + 12, selected == 1);
-	print_button(win, " Help ", y, x + 24, selected == 2);
-	print_button(win, " Save ", y, x + 36, selected == 3);
-	print_button(win, " Load ", y, x + 48, selected == 4);
-	print_button(win, "Compare", y, x + 60, selected == 5);
+	print_button(win, " Exit ", y, x + 10, selected == 1);
+	print_button(win, " Help ", y, x + 20, selected == 2);
+	print_button(win, " Save ", y, x + 30, selected == 3);
+	print_button(win, " Load ", y, x + 40, selected == 4);
+	print_button(win, "Compare", y, x + 50, selected == 5);
 
  	wmove(win, y, x + 1 + 12 * selected);
  	wrefresh(win);
@@ -366,6 +366,8 @@ do_resize:
  		case ' ':
  		case 's':
  		case 'y':
+		case 'd':
+		case 'f':
  		case 'n':
  		case 'm':
  		case '/':
@@ -398,8 +400,10 @@ do_resize:
  			case 'z':
  				return 10;
  			case KEY_F(2):		/* Differences between .config files view */
+			case 'd':
  				return 40;
  			case KEY_F(4):		/* Save to file differences between .config files */
+			case 'f':
  				return 60;
  			case '\n':
  				return button == 5 ? 50 : button;	/* Workaround for Compare button */
scripts/kconfig/mconf.c +2 -2
@@ -137,9 +137,9 @@ static const char mconf_readme[] =
  "built-in, _: for a symbol excluded, M: for a symbol as module and #: for\n"
  "a symbol absent in the loaded \".config\" file, meaning therefore a new feature.\n"
  "\n"
-"Once loaded the .config file to compare, using the <F2> key a view will\n"
+"Once loaded the .config file to compare, using the <F2> or 'D' key a view will\n"
  "be displayed listing the differences between the two .config files, using\n"
-"the <F4> key instead, you can save to a file these differences.\n"
+"the <F4> or 'F' key instead, you can save to a file these differences.\n"
  "\n"
  "Other information\n"
  "-----------------\n"
Signature · 1 line
Franco Martelli