Skip to content

DOC-COMPATIBILITY: struct s_nation uid field too small for modern systems #2

@smooge

Description

@smooge

Bug Type

DOC-COMPATIBILITY - Portability problem with data structure sizing

Severity

Medium

Phase Discovered

Phase 4.4: Warning elimination - main.c modernization

Files Affected

  • data.h:618 - struct s_nation definition
  • main.c:498,501 - uid comparison operations requiring casts

Description

The struct s_nation uses 'short int uid' for storing user IDs, but modern Unix systems use uid_t (unsigned int, 32-bit). This creates both compilation warnings and potential data truncation issues.

Code Location

data.h:618

main.c:498,501 - Requires casts: (uid_t)curntn->uid

Impact Assessment

  • Compilation: Sign-compare warnings between short int and uid_t
  • Data Integrity: UIDs > 32767 would be truncated when stored in short
  • Portability: Modern systems commonly have UIDs beyond short int range
  • File Format: Changing struct affects saved game file compatibility

Recommended Resolution

  1. Immediate: Apply casts in main.c to eliminate warnings (current approach)
  2. Long-term: Modernize struct field to uid_t with migration strategy
  3. Migration: Implement file format versioning for backward compatibility
  4. Testing: Verify no saved game files use UIDs > 32767

Session History

  • Phase 4.4 warning elimination session
  • Applied temporary casts to resolve compilation warnings
  • Identified structural modernization need for future phase

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions