diff mbox

warning: explain restrictness difference in error messages

Message ID 20180617101747.53620-1-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Luc Van Oostenryck June 17, 2018, 10:17 a.m. UTC
For sparse, a difference of restrictness (__bitwise) is reported
as a difference of base types. That's correct but for the user it
may be more informative to know if teh error is one concerning
the normal C rules or one related to sparse's extensions.

Change this by using "different restrictness" or "different
restricted types", depending if one or both types is a concerned.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 evaluate.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Ramsay Jones June 18, 2018, 12:15 a.m. UTC | #1
On 17/06/18 11:17, Luc Van Oostenryck wrote:
> For sparse, a difference of restrictness (__bitwise) is reported
> as a difference of base types. That's correct but for the user it
> may be more informative to know if teh error is one concerning
> the normal C rules or one related to sparse's extensions.
> 
> Change this by using "different restrictness" or "different
> restricted types", depending if one or both types is a concerned.

"different restrictness" sounds absolutely awful! :)

[Also, I don't think 'restrictness' is actually a word].

Hmm, I think "different restricted types" or "different restricted
base types" would work for all messages.

ATB,
Ramsay Jones
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luc Van Oostenryck June 18, 2018, 4:20 a.m. UTC | #2
On Mon, Jun 18, 2018 at 01:15:38AM +0100, Ramsay Jones wrote:
> 
> 
> On 17/06/18 11:17, Luc Van Oostenryck wrote:
> > For sparse, a difference of restrictness (__bitwise) is reported
> > as a difference of base types. That's correct but for the user it
> > may be more informative to know if teh error is one concerning
> > the normal C rules or one related to sparse's extensions.
> > 
> > Change this by using "different restrictness" or "different
> > restricted types", depending if one or both types is a concerned.
> 
> "different restrictness" sounds absolutely awful! :)
> 
> [Also, I don't think 'restrictness' is actually a word].

Well, let say I granted myself some artistic licenses but sounding
awful (to a native speaker) is annoying. However, googling for it
reports some usages, including in scientific books.
 
> Hmm, I think "different restricted types" or "different restricted
> base types" would work for all messages.

There is two different cases:
1) '__be32' vs. 'int'
2) '__be32' vs. '__le32'

In 1), __be32 is restricted while int is not. In 2) both types are
restricted but are different restricted types. I would have a distinct
error message for them.

BTW, I'm not at all found of the use of the word 'restricted' in the
error message (and sparse's code) while the corresponding attribute
is 'bitwise' and 'restrict' is an unrelated keyword since C99.
So maybe we should use instead "different bitwise types" and ...
"different bitwiseness"? ;)

Suggestions are more than welcome.

-- Luc 
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ramsay Jones June 18, 2018, 4:56 p.m. UTC | #3
On 18/06/18 05:20, Luc Van Oostenryck wrote:
[snip]
>> Hmm, I think "different restricted types" or "different restricted
>> base types" would work for all messages.
> 
> There is two different cases:
> 1) '__be32' vs. 'int'
> 2) '__be32' vs. '__le32'

Indeed.

> In 1), __be32 is restricted while int is not. In 2) both types are
> restricted but are different restricted types. I would have a distinct
> error message for them.

I guess I don't see a great need for different messages.

> BTW, I'm not at all found of the use of the word 'restricted' in the
> error message (and sparse's code) while the corresponding attribute
> is 'bitwise' and 'restrict' is an unrelated keyword since C99.

Yes, that caused me to stumble quite often in the first few years! :)

So, I agree it would be good to fix up the code ...

> So maybe we should use instead "different bitwise types" and ...
> "different bitwiseness"? ;)

... and my only concern with new wording in the messages - would
this cause kernel developers to double take? (non-kernel developers
would most likely not be affected, since they don't use 'bitwise'
types anyway).

Having said that, I much prefer something like:

  1) "mixing 'bitwise' and normal types"
  2) "different 'bitwise' types"

Or, something like that. ;-)

ATB,
Ramsay Jones

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luc Van Oostenryck June 18, 2018, 6:36 p.m. UTC | #4
On Mon, Jun 18, 2018 at 05:56:01PM +0100, Ramsay Jones wrote:
> 
> 
> On 18/06/18 05:20, Luc Van Oostenryck wrote:
> [snip]
> >> Hmm, I think "different restricted types" or "different restricted
> >> base types" would work for all messages.
> > 
> > There is two different cases:
> > 1) '__be32' vs. 'int'
> > 2) '__be32' vs. '__le32'
> 
> Indeed.
> 
> > In 1), __be32 is restricted while int is not. In 2) both types are
> > restricted but are different restricted types. I would have a distinct
> > error message for them.
> 
> I guess I don't see a great need for different messages.

In my eyes, the second case is much more critical than the first
but I agree, there isn't much needs.
 
> > BTW, I'm not at all found of the use of the word 'restricted' in the
> > error message (and sparse's code) while the corresponding attribute
> > is 'bitwise' and 'restrict' is an unrelated keyword since C99.
> 
> Yes, that caused me to stumble quite often in the first few years! :)
> 
> So, I agree it would be good to fix up the code ...
> 
> > So maybe we should use instead "different bitwise types" and ...
> > "different bitwiseness"? ;)
> 
> ... and my only concern with new wording in the messages - would
> this cause kernel developers to double take? (non-kernel developers
> would most likely not be affected, since they don't use 'bitwise'
> types anyway).

Yes, I suppose too that 'bitwise' is only/mainly used for the kernel.
I also suppose that some, maybe most, kernel devs would welcome the
change
 
> Having said that, I much prefer something like:
> 
>   1) "mixing 'bitwise' and normal types"
>   2) "different 'bitwise' types"
> 
> Or, something like that. ;-)

That's sound good and is not to long. I would just use 'plain' instead of
'normal' because ... normally I don't use the word 'normal'.

I'll keep this change with the new wording but I won't apply it soon.
Same for the change in the code.

Thanks for the opinion and suggestion.
-- Luc
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ramsay Jones June 18, 2018, 11:36 p.m. UTC | #5
On 18/06/18 19:36, Luc Van Oostenryck wrote:
> On Mon, Jun 18, 2018 at 05:56:01PM +0100, Ramsay Jones wrote:
[snip]
>> Having said that, I much prefer something like:
>>
>>   1) "mixing 'bitwise' and normal types"
>>   2) "different 'bitwise' types"
>>
>> Or, something like that. ;-)
> 
> That's sound good and is not to long. I would just use 'plain' instead of
> 'normal' because ... normally I don't use the word 'normal'.

Ah, yes, thank you! I was searching for the 'plain types' phrase
but just couldn't remember it! :D

Thanks!

ATB,
Ramsay Jones
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/evaluate.c b/evaluate.c
index 0ff617b1f..5fd0edce7 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -714,8 +714,11 @@  const char *type_difference(struct ctype *c1, struct ctype *c2,
 
 		move1 = move2 = 1;
 		type = t1->type;
-		if (type != t2->type)
+		if (type != t2->type) {
+			if (type == SYM_RESTRICT || t2->type == SYM_RESTRICT)
+				return "different restrictness";
 			return "different base types";
+		}
 
 		switch (type) {
 		default:
@@ -724,7 +727,7 @@  const char *type_difference(struct ctype *c1, struct ctype *c2,
 				     type);
 			return "bad types";
 		case SYM_RESTRICT:
-			return "different base types";
+			return "different restricted types";
 		case SYM_UNION:
 		case SYM_STRUCT:
 			/* allow definition of incomplete structs and unions */
@@ -1404,6 +1407,8 @@  static int check_assignment_types(struct symbol *target, struct expression **rp,
                         goto Cast;
                 }
 		*typediff = "different base types";
+		if ((tclass ^ sclass) & TYPE_RESTRICT)
+			*typediff = "different restrictness";
 		return 0;
 	}