Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added API allowing user to choose settings at runtime - replacement of PR#49 #51

Merged
merged 3 commits into from
Aug 24, 2023

Conversation

AniruddhaKanhere
Copy link
Member

@AniruddhaKanhere AniruddhaKanhere commented Aug 11, 2023

Description

Thank you for your changes @phelter - I am creating this PR on your behalf so that we can review this.

Test Steps

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

This should replace #49.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Member Author

@AniruddhaKanhere AniruddhaKanhere left a comment

Choose a reason for hiding this comment

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

@phelter and @htibosch can you please look at this PR?

Comment on lines +92 to +94
time_t ff_atime;
time_t ff_mtime;
time_t ff_ctime;
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this a backward compatible change? An in what happens to users using these fields? Or are these internal?

Copy link
Contributor

@phelter phelter Aug 14, 2023

Choose a reason for hiding this comment

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

No it is not backwards compatible - This is to fix #50 . What is allowed and not allowed in terms of breaking compatibility for Lab projects?

Copy link
Contributor

Choose a reason for hiding this comment

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

@phelter asked:

What is allowed and not allowed in terms of breaking compatibility for Lab projects?

There is not an official guideline about "breaking compatibility". I'd like to break as little as possible, and avoid complex or tricky constructions like the use of #undef.

I just compiled a big Xilinx project, which contains an FTP-server and a compression module, all with ffconfigTIME_SUPPORT defined.

I must say that the code rarely refers to the one of the 3 fields (st_[amc]time).

Another way to void compilation errors would be :

#if( DOWNWARD_COMPATIBLE )
	#define st_atime    ff_atime
	#define st_mtime    ff_mtime
	#define st_ctime    ff_ctime
#endif

but that might cause problems in applications that also use stdio.h

Note that the compiler error is easy to understand:

gzip.cpp:746: error: 'struct stat_type' has no member named 'st_mtime'

Can you add some comments about the compatibility break?
Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

If compatibility with many different flavors of environments what I'd suggest is:

  1. Avoid #defines in your code - if you must then prefix them with something like FREERTOS_PLUS_FAT_<NAME> to ensure there is a low risk of them conflicting with other #defines in other libraries.
  2. Own your naming convention and typenames for your project. In this instance FF_STAT shares the linux names and portion of that struct. If you intend on supporting Linux AND other libraries - need to own the structure. FWIW this struct also doesn't meet the FreeRTOS naming criteria of adding an x prefix.
  3. Do not copy for the sake of copying other environment's structures. If you intend your API to be used as a wrapper for others then own the structure definition and do the translation to the other platforms.

@htibosch - are you referring to adding comments in the code about compatibility issues? If so I'd suggest the code is not the place for that, but release notes between versions is a better place to provide that type of information - i.e. provide search/replace information on compatibility breaks. Happy to provide a sed script if you like. Something like:

sed -e 's/st_(a|m|c)time/ff_$1time/g' *.c

Comment on lines +1140 to +1142
pxStatBuffer->ff_atime = prvFileTime( &( xDirEntry.xAccessedTime ) );
pxStatBuffer->ff_mtime = prvFileTime( &( xDirEntry.xModifiedTime ) );
pxStatBuffer->ff_ctime = prvFileTime( &( xDirEntry.xCreateTime ) );
Copy link
Member Author

Choose a reason for hiding this comment

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

Same here. Would this break existing users code?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please have a look at my earlier response?

Copy link
Contributor

Choose a reason for hiding this comment

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

This would only break existing user code if they are accessing the values inside the pxStatBuffer in their code in some way associated with st_[a|m|c]time. It can be mitigated by providing users a description of the breaking change in this Lab-Project based repo.

The other option is to possibly investigate replacing the entire struct for Linux based examples with the linux stat structure instead of using home-grown version, and ensuring compatibility between the FF_Stat and linux stat is maintained - see #50 (comment).

@AniruddhaKanhere
Copy link
Member Author

To fix the formatting, would you please apply this patch @phelter?
formattingDiff.patch

@AniruddhaKanhere
Copy link
Member Author

@phelter and @htibosch,

We have been discussing this internally as this is a breaking change. I shall share what we discussed and the conclusions drawn here:

  • What is the expectation around breaking changes in labs projects?

    • The labs projects are experimental and are there for community's benefit and review. While we do not make breaking changes for non-critical issues like to make the API look better, the expectation is that the code can and will change if the reason is justified and the code has a bug.
  • What about this PR? Are we going to accept it?

    • Since there is a conflict of definitions with a standard file, it seems prudent that we accept this change even though it would break existing users code. However, we shall tag the commit just before this PR is merged so that folks who do not want to take in this breaking change can do that by checking out the tag.

@htibosch
Copy link
Contributor

Thank you @phelter for this PR, I approve it as it is.
I checked my projects and in fact the struct is rarely accessed, easy enough to change it.

@AniruddhaKanhere AniruddhaKanhere merged commit 25129e5 into FreeRTOS:main Aug 24, 2023
3 checks passed
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.

4 participants