Skip to content

Commit

Permalink
Make contains/excludes constraints compile for lists of unsigned valu…
Browse files Browse the repository at this point in the history
…es. (#19730)

Two changes here:

1) In chip_tests_iterate_expected_list, we were marking each individual value as
   an array (because "this.isArray" would be true in general when this helper is
   used).  That caused asTypedLiteral to fail to map it to an integer basic type
   and hence we were not adding with the proper suffixes, and that lead to
   signed-to-unsigned comparison errors.  This is the actual bugfix.

2) In asTypedLiteral, we really should be suffixing uint8_t with "U".  It's not
   clear why compilers don't complain about signed-to-unsigned compares for that
   type the way they do for uint16/32/64_t, but conceptually this is the right
   thing to do.

Fixes #19726
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jul 22, 2023
1 parent f4cce42 commit 0ffa059
Show file tree
Hide file tree
Showing 4 changed files with 3,788 additions and 3,786 deletions.
3 changes: 1 addition & 2 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,7 @@ function chip_tests_iterate_expected_list(values, options)
{
values = values.map(value => {
return {
global: this.global, parent: this.parent, name: this.name, type: this.type, isArray: this.isArray,
isNullable: this.isNullable, value: value,
global: this.global, parent: this.parent, name: this.name, type: this.type, isArray: false, isNullable: false, value: value,
}
});

Expand Down
3 changes: 2 additions & 1 deletion src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ async function asTypedExpression(value, type)
return `static_cast<${resultType}>(${value})`;
}

async function asTypedLiteral(value, type)
async function asTypedLiteral(value, type, cookie)
{
const valueIsANumber = !isNaN(value);
if (!valueIsANumber) {
Expand All @@ -335,6 +335,7 @@ async function asTypedLiteral(value, type)
return value + 'L';
case 'int64_t':
return value + 'LL';
case 'uint8_t':
case 'uint16_t':
return value + 'U';
case 'uint32_t':
Expand Down
Loading

0 comments on commit 0ffa059

Please sign in to comment.