linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Franco Martelli <martellif67@gmail.com>
To: Randy Dunlap <rdunlap@infradead.org>, masahiroy@kernel.org
Cc: linux-kbuild@vger.kernel.org
Subject: Re: [PATCH 1/1] Kconfig: Added compare capabilities for mconf
Date: Mon, 2 Jun 2025 15:41:13 +0200	[thread overview]
Message-ID: <ddf7c0be-48ce-47d5-acc6-2e9e5aae64b4@gmail.com> (raw)
In-Reply-To: <2e8cb14e-abb7-4850-a1fe-31bad55bb04b@infradead.org>

On 02/06/25 at 02:59, Randy Dunlap wrote:
> 
> 
> 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?

> 
> 
>> Signed-off-by: Franco Martelli <martellif67@gmail.com>
>> ---
>>   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(-)
>>
>> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
>> index ac95661a1c9d..078d058c01d7 100644
>> --- a/scripts/kconfig/confdata.c
>> +++ b/scripts/kconfig/confdata.c
>> @@ -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)
> 
>     static char *mask_xrealloc(...
> (no space after '*')
> 
>> +{
>> +	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)
> 
> ditto.
> 
>> +{
> 
>> +}
> 
>> @@ -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);
> 
> 		                           occurred
> 
>> +		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;
> 
> 

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.

-- 
Franco Martelli

  reply	other threads:[~2025-06-02 13:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-01 18:40 [PATCH 0/1] kconfig: comparison feature between two .config files added to mconf Franco Martelli
2025-06-01 18:40 ` [PATCH 1/1] Kconfig: Added compare capabilities for mconf Franco Martelli
2025-06-02  0:59   ` Randy Dunlap
2025-06-02 13:41     ` Franco Martelli [this message]
2025-06-02 13:52       ` Miguel Ojeda
2025-06-02 16:42       ` Randy Dunlap
2025-06-02  1:04 ` [PATCH 0/1] kconfig: comparison feature between two .config files added to mconf Randy Dunlap
2025-06-02  3:37   ` Randy Dunlap
2025-06-02 13:35     ` Franco Martelli
  -- strict thread matches above, loose matches on Subject: below --
2025-10-30 14:13 [PATCH 0/1] Kconfig: Added compare capabilities for mconf Franco Martelli
2025-10-30 14:13 ` [PATCH 1/1] " Franco Martelli
2025-11-11 14:48   ` Nicolas Schier
2025-11-11 20:37     ` Franco Martelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ddf7c0be-48ce-47d5-acc6-2e9e5aae64b4@gmail.com \
    --to=martellif67@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).