Skip to content

Conversation

TheCloudlet
Copy link
Collaborator

No description provided.

@TheCloudlet
Copy link
Collaborator Author

Suggestion in CWE-468
--> Always use array indexing instead of direct pointer manipulation.

I do not think there is a way to us array indexing here.

@gagachang
Copy link
Contributor

gagachang commented Feb 19, 2023

How about using union:

union {
    uint32_t csr_time_32[2];
    uint64_t csr_time_64;
};

@TheCloudlet
Copy link
Collaborator Author

Hi @gagachang,

Maybe this new change has a better readability.
What do you think?

@gagachang
Copy link
Contributor

Yes, it looks better. Minor suggestion:

rv->csr_time[0] = t & 0xFFFFFFFF;

Actually, I think two dedicated variables for time is OK, since rv32emu targets RV32 system.
The spec defines two CSRs for time on RV32 system.

uint32_t csr_time;
uint32_t csr_timeh;

@TheCloudlet
Copy link
Collaborator Author

Hi @gagachang
Thank you for your code review and suggestion

@jserv jserv merged commit fd4de56 into sysprog21:master Feb 19, 2023
2011eric pushed a commit to 2011eric/rv32emu that referenced this pull request Jul 22, 2023
vestata pushed a commit to vestata/rv32emu that referenced this pull request Jan 24, 2025
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