[generators] gen_periodic: no need to hardcode number of slots

use {{ NULL }} instead of {{NULL, NULL, NULL, NULL}} to initialize all slots to NULL

- and fix return of register_periodic_telemetry
This commit is contained in:
Felix Ruess
2015-11-24 23:16:16 +01:00
parent 8a51abbebb
commit 7b8aee102b
2 changed files with 4 additions and 8 deletions
+2 -2
View File
@@ -46,8 +46,8 @@ struct periodic_telemetry pprz_telemetry = { TELEMETRY_NB_MSG, telemetry_msgs, t
*/
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, const char *_msg, telemetry_cb _cb)
{
// return FALSE if NULL is passed as periodic_telemetry
if (_pt == NULL) { return FALSE; }
// return if NULL is passed as periodic_telemetry
if (_pt == NULL) { return -1; }
// look for message name
uint8_t i, j;
for (i = 0; i < _pt->nb; i++) {
+2 -6
View File
@@ -163,12 +163,8 @@ let print_message_table = fun out_h xml ->
fprintf out_h "};\n\n";
fprintf out_h "#define TELEMETRY_CBS_NULL { \\\n";
for i = 1 to (Hashtbl.length messages) do
fprintf out_h " {{";
(* TODO: fix hardcoded value of 4 *)
for j = 1 to 4 do
fprintf out_h "NULL, "
done;
fprintf out_h "}}, \\\n"
(* use one 0 to init all slots (number TELEMETRY_NB_CBS) to NULL *)
fprintf out_h " {{ NULL }}, \\\n";
done;
fprintf out_h "}\n\n"