Skip to content

Server fails to respond on IPP requests due to enum size assumption. #141

@SebastiaanMerckx

Description

@SebastiaanMerckx

Describe the bug
I've been porting the application to a microcontroller using zephyr. It receives an IPP request, but the received operation_id is 0. Eventually, it seems that the size of enums like ipp_op_t and ipp_status_t (in typedef union _ipp_request_u is not necessarily the size of an int (op_status).
Therefore, the different union members do not necessarily align. In our case, the size of an enum was 2 bytes, size of int 4 bytes.

To Reproduce
Steps to reproduce the behavior:

  1. Compile with a compiler that wraps enums in 2 bytes. Verify that the union structs do not align when receiving an IPP packet. _ipp_request_u.any.op_status != _ipp_request_u.op.operation_id.

Possible solutions
I'm not sure what's preferred...

  • I forced the enums to be at least "int" size by adding an enum value of 0xFFFFFFFF but evidently that only works on 32-bit systems.
  • Alternatively, the enums in the struct could be replaced with ints.
  • But these solutions probably don't ensure correct behavior. Maybe the structs even need to be packed to make sure that the variable align?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions