Skip to content

Standardize struct + typedef usage.#1704

Merged
mossmann merged 2 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/consistent-structs
Apr 7, 2026
Merged

Standardize struct + typedef usage.#1704
mossmann merged 2 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/consistent-structs

Conversation

@antoinevg
Copy link
Copy Markdown
Member

@antoinevg antoinevg commented Mar 23, 2026

Depends on #1703


This PR standardizes struct definitions for HackRF firmware and resolves the ambiguity between declarations such as struct type_t and typedef struct type_t type_t

We prefer two formats:

1. Simple struct definitions:

struct definitions of the form:

struct fpga_driver_t;
typedef struct fpga_driver_t fpga_driver_t;

struct fpga_driver_t {
    ice40_spi_driver_t* bus;
    uint8_t regs[FPGA_NUM_REGS];
    uint8_t regs_dirty;
};

are refactored to:

typedef struct {
	ice40_spi_driver_t* bus;
	uint8_t regs[FPGA_NUM_REGS];
	uint8_t regs_dirty;
} fpga_driver_t;

2. Self-referential struct definitions:

Self-referential definitions of the form:

struct max5864_driver_t;
typedef struct max5864_driver_t max5864_driver_t;

struct max5864_driver_t {
    spi_bus_t* const bus;
    void (*target_init)(max5864_driver_t* const drv);
};

are refactored to:

typedef struct _max5864_driver_t {
    spi_bus_t* const bus;
    void (*target_init)(struct _max5864_driver_t* const drv);
} max5864_driver_t;

@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch from 65b74ca to ac4edd5 Compare March 24, 2026 07:43
@mossmann mossmann self-requested a review March 24, 2026 14:08
@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch 6 times, most recently from d97be1f to 943a600 Compare March 31, 2026 09:01
This was referenced Apr 2, 2026
@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch from 943a600 to 046b6a7 Compare April 2, 2026 07:37
@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch from 046b6a7 to 4e5fa68 Compare April 7, 2026 08:50
Comment thread firmware/common/cpld_jtag.h Outdated
@antoinevg antoinevg force-pushed the antoinevg/consistent-structs branch from 4e5fa68 to d49b5b1 Compare April 7, 2026 14:52
@antoinevg antoinevg requested a review from mossmann April 7, 2026 14:53
Copy link
Copy Markdown
Member

@mossmann mossmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mossmann mossmann merged commit 159050b into greatscottgadgets:main Apr 7, 2026
41 checks passed
@antoinevg antoinevg deleted the antoinevg/consistent-structs branch April 21, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants