Actions
Bug #858
closed1.4.3: src/detect.h has anonymous structs in typedefs
Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Affected Versions:
Effort:
Difficulty:
Label:
Description
Solaris Sun Studio 12.3 compiler adheres to the standard much better than gcc, it doesn't like anonymous structs.
"detect-app-layer-event.c", line 152: improper member use: alproto "detect-app-layer-event.c", line 153: improper member use: alproto "detect-app-layer-event.c", line 159: improper member use: alproto "detect-app-layer-event.c", line 163: improper member use: flags "detect-byte-extract.c", line 574: improper member use: alproto "detect-byte-extract.c", line 592: improper member use: flags "detect-byte-extract.c", line 596: improper member use: flags "detect-byte-extract.c", line 600: improper member use: alproto "detect-byte-extract.c", line 671: improper member use: alproto "detect-bytejump.c", line 548: improper member use: alproto "detect-bytejump.c", line 578: improper member use: flags "detect-bytejump.c", line 582: improper member use: flags "detect-bytejump.c", line 586: improper member use: alproto "detect-bytejump.c", line 642: improper member use: alproto "detect-bytetest.c", line 469: improper member use: alproto "detect-bytetest.c", line 499: improper member use: flags "detect-bytetest.c", line 503: improper member use: flags "detect-bytetest.c", line 507: improper member use: alproto "detect-bytetest.c", line 578: improper member use: alproto "detect.c", line 501: improper member use: flags "detect.c", line 502: improper member use: alproto "detect.c", line 502: improper member use: alproto "detect.c", line 503: improper member use: alproto "detect.c", line 515: improper member use: flags "detect.c", line 516: improper member use: dsize_low "detect.c", line 516: improper member use: dsize_high [...]
The offending typedefs:
src/detect.h: 325 typedef struct SignatureHeader_ { 326 union { 327 struct { 328 uint32_t flags; 329 uint16_t alproto; 330 uint16_t dsize_low; 331 }; 332 uint64_t hdr_copy1; 333 }; 334 union { 335 struct { 336 uint16_t dsize_high; 337 uint16_t mpm_pattern_id_div_8; 338 }; 339 uint32_t hdr_copy2; 340 }; 341 union { 342 struct { 343 uint8_t mpm_pattern_id_mod_8; 344 SignatureMask mask; 345 SigIntId num; /**< signature number, internal id */ 346 }; 347 uint32_t hdr_copy3; 348 }; 349 /** pointer to the full signature */ 350 struct Signature_ *full_sig; 351 } SignatureHeader; 363 typedef struct Signature_ { 364 union { 365 struct { 366 uint32_t flags; 367 uint16_t alproto; 368 uint16_t dsize_low; 369 }; 370 uint64_t hdr_copy1; 371 }; 372 union { 373 struct { 374 uint16_t dsize_high; 375 uint16_t mpm_pattern_id_div_8; 376 }; 377 uint32_t hdr_copy2; 378 }; 379 union { 380 struct { 381 uint8_t mpm_pattern_id_mod_8; 382 SignatureMask mask; 383 SigIntId num; /**< signature number, internal id */ 384 }; 385 uint32_t hdr_copy3; 386 };
I've given the structs names (first, second, third) and gone through all 75 of the src/detect*.[c|h] files where they are referenced and fixed the code. See attached diff. Feel free to edit the struct names to suit their purpose :)
All the detect* files now compile with just warnings, not errors.
Files
Updated by Mark Solaris almost 11 years ago
This thread has more on anonymous structs in unions.
http://stackoverflow.com/questions/12653500/how-to-access-a-struct-member-inside-a-union-in-c
Updated by Mark Solaris almost 11 years ago
- File detect.diffs detect.diffs added
Added a fix for src/util-threshold-config.c to the diff, it's the same struct problem so bundling into the same diff.
Actions