Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Tagged task output functions #5

Merged
merged 9 commits into from
Apr 25, 2024
Merged

Tagged task output functions #5

merged 9 commits into from
Apr 25, 2024

Conversation

JoseMatos03
Copy link
Collaborator

@JoseMatos03 JoseMatos03 commented Apr 3, 2024

Adds functionality that writes and reads tagged tasks to a binary file.

Writing a tagged_task now writes in binary, instead of text.
Added a tagged_task_get_size function.
Removed program stdout to files functions.
Copy link
Owner

@voidbert voidbert left a comment

Choose a reason for hiding this comment

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

There are a lot of things wrong here, some cause your bugs and some are grave structural programs.

  • &(struct timespec){.tv_sec = 1, .tv_nsec = 0} may compile but is not standard C code. If you had ran a debugger through the code (please do it ), you'd realize why it's failing. When setting the time, its value is {.tv_sec = 0, .tv_nsec = 0}, and task_t considers this value of a timestamp to mean an unset time.

  • You shouldn't be opening the log file every time you read from or write to it. Create a log_file_t type containing the descriptor, pass it around, and close it when needed. Also, please rename your module log_file, as output is way too generic.

  • You are writing textual data to the file. Define a binary format and use it.

  • You aren't doing error handling for functions other than open. Please do it and set errno accordingly.

  • Don't use ftruncate. Use O_TRUNC when you open the file.

  • Don't print to stdout whatever you see in a file when reading. Define some sort of iterator (or reader) and use it outside. This needs to be generic.

In summary, this is pretty much do for a rewrite.

- Renamed module from "output" to "log_file"
- Created a "log_file_t" type to pass descriptors around
- Added error handling
- Added a generic task iterator
Copy link
Owner

@voidbert voidbert left a comment

Choose a reason for hiding this comment

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

I changed a quite a few things you were doing wrong. We can discuss it personally so that you can learn how to do file management the right way. A few things are still subject to change (e.g.: variable length tasks), but this works as is and can be merged now.

@voidbert voidbert requested a review from JosLopes April 22, 2024 23:58
@voidbert voidbert merged commit d7b601d into main Apr 25, 2024
2 checks passed
@voidbert voidbert deleted the output branch April 25, 2024 12:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants