command: Encode MESSAGE_MIN in command_parser->max_size
Add the message minimum into the stored constant so it does not need to be added at run-time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -30,7 +30,8 @@ def error(msg):
|
||||
|
||||
def build_parser(parser, iscmd, all_param_types):
|
||||
if parser.name == "#empty":
|
||||
return "\n // Empty message\n .max_size=0,"
|
||||
return "\n // Empty message\n .max_size=%d," % (
|
||||
msgproto.MESSAGE_MIN,)
|
||||
if parser.name == "#output":
|
||||
comment = "Output: " + parser.msgformat
|
||||
else:
|
||||
@@ -54,8 +55,9 @@ def build_parser(parser, iscmd, all_param_types):
|
||||
+ types.count('PT_buffer'))
|
||||
out += " .num_args=%d," % (num_args,)
|
||||
else:
|
||||
max_size = min(msgproto.MESSAGE_MAX - msgproto.MESSAGE_MIN
|
||||
, 1 + sum([t.max_length for t in parser.param_types]))
|
||||
max_size = min(msgproto.MESSAGE_MAX,
|
||||
(msgproto.MESSAGE_MIN + 1
|
||||
+ sum([t.max_length for t in parser.param_types])))
|
||||
out += " .max_size=%d," % (max_size,)
|
||||
return out
|
||||
|
||||
|
Reference in New Issue
Block a user