Skip to content

Commit e562cc7

Browse files
committed
optiga: u2f_counter_inc return true for success
u2f_counter_inc (return type bool) incorrectly returned 0 (false) for success.
1 parent d1c8d6f commit e562cc7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/optiga/optiga.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,8 @@ static int _write_arbitrary_data(const arbitrary_data_t* data)
776776
sizeof(data->bytes));
777777
if (res != OPTIGA_LIB_SUCCESS) {
778778
util_log("could not write arbitrary %x", res);
779-
return res;
780779
}
781-
return 0;
780+
return res;
782781
}
783782
#endif
784783

@@ -981,7 +980,7 @@ static int _configure_object_arbitrary_data(void)
981980
}
982981
if (lcso >= LCSO_STATE_OPERATIONAL) {
983982
util_log("_configure_object_arbitrary_data: already setup");
984-
return 0;
983+
return OPTIGA_LIB_SUCCESS;
985984
}
986985
util_log("_configure_object_arbitrary_data: setting up");
987986

@@ -994,11 +993,11 @@ static int _configure_object_arbitrary_data(void)
994993
// Initialize arbitrary data, all zeroes.
995994
const arbitrary_data_t arbitrary_data = {0};
996995
int write_res = _write_arbitrary_data(&arbitrary_data);
997-
if (write_res) {
996+
if (write_res != OPTIGA_LIB_SUCCESS) {
998997
util_log("could not initialize arbitrary data");
999998
return write_res;
1000999
}
1001-
return 0;
1000+
return OPTIGA_LIB_SUCCESS;
10021001
}
10031002

10041003
static int _configure_object_counter(void)
@@ -1799,7 +1798,7 @@ bool optiga_u2f_counter_set(uint32_t counter)
17991798
return false;
18001799
}
18011800
data.fields.u2f_counter = counter;
1802-
return _write_arbitrary_data(&data) == 0;
1801+
return _write_arbitrary_data(&data) == OPTIGA_LIB_SUCCESS;
18031802
}
18041803
#endif
18051804

@@ -1812,7 +1811,8 @@ bool optiga_u2f_counter_inc(uint32_t* counter)
18121811
}
18131812
data.fields.u2f_counter += 1;
18141813
*counter = data.fields.u2f_counter;
1815-
return _write_arbitrary_data(&data);
1814+
1815+
return _write_arbitrary_data(&data) == OPTIGA_LIB_SUCCESS;
18161816
}
18171817
#endif
18181818

0 commit comments

Comments
 (0)