-
Notifications
You must be signed in to change notification settings - Fork 93
Windows support #510
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
Windows support #510
Conversation
bafbd71 to
07a2da6
Compare
Author: Author Name vandel_van@hotmail.com
|
I would like to notify this comment in advance before this PR goes to compilable... I know you are working so hard on this PR and also I know you want to support windows again in the IBM storage archive product. But I must strongly disagree to this PR. Because this PR has no benefit to the normal open source users who are using the code in this repository. On the other hand code change is big and impact of the readability of codes are really big. I have so many comments and complains but top-3 of my comments are First, please don't introduce Second, please don't use For example, Last, please write macros to keep the C language context. I believe macro feature can easily ruins the C language context and create new your own langage. But this project is clearly written by C please do not corrupt the readability for C developers. I strongly recommend that you need to use inline function as much possible, that is a reason taht we choose C99. For example, this macro call confuses C developers in short period. They don't think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want to use arch_ prefix for POSIX functions.
I believe your change doesn't make this code compilable on Visual C. This just a part of Visual C compilation only in IBM.
So I believe you need to minimize the code change because there is no benefit to this project at all!
My recommendation is just use POSIX functions as POSIX function name.
Honestly, I cannot understand why you want to replace POSIX function name to name with arch_ prefix. But if it is to suppress the waring message in Visual C, please suppress it with pragma declaration like below.
#ifdef _MSC_VER
#pragma warning(suppress : 4996)
...
#endifSee also, https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-write?view=msvc-170.
Second best is
#ifdef _MSC_VER
#define write _write
...
#endif
src/libltfs/arch/ltfs_arch_ops.h
Outdated
| #define INVALID_KEY UINT_MAX | ||
|
|
||
|
|
||
| #define arch_vsprintf(buffer,bufferCount, fmt, ...) vsprintf_s((buffer), (bufferCount), (fmt), __VA_ARGS__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use camel case bufferCount.
This is macro definition, so long variable name is not needed.
piste-jp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I roughly make comments. They are not everything.
I just at a glance and make comments.
|
|
||
| /* Store new write request */ | ||
| new_req = calloc(1, sizeof(struct write_request)); | ||
| new_req = (struct write_request*)calloc(1, sizeof(struct write_request)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this cast is needed.
| struct timer_info timerinfo; | ||
| struct unified_data *priv = iosched_handle; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not keep the leading spaces in an empty line.
| } | ||
|
|
||
| p = fopen(path, PROFILER_FILE_MODE); | ||
| arch_fopen(path, PROFILER_FILE_MODE,p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why fopen_s() is needed on windows?
| strcat((char *) priv.dk_list, (char *) key[i].dk); | ||
| strcat((char *) priv.dk_list, ":"); | ||
| strcat((char *) priv.dk_list, (char *) key[i].dki); | ||
| arch_strcat((char *) priv.dk_list, dk_list_len, "/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot understand why strcat_s() is needed here. Every input string can be handled safely in this function...
If you have a reason please explain it by comment and add strcat_s() function into linux side. I don't like Annex K, but it is better than this, if you have a strong reason.
src/libltfs/arch/ltfs_arch_ops.h
Outdated
|
|
||
| #define arch_access(filename, mode) _access((filename), (mode)) | ||
|
|
||
| #define arch_xmlfree(ptr) xmlFree((ptr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend this.
#define xmlfree xmlFree
src/libltfs/arch/ltfs_arch_ops.h
Outdated
|
|
||
| #define arch_access(filename, mode) access(filename, mode) | ||
|
|
||
| #define arch_xmlfree(ptr) arch_safe_free(ptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend that this line is removed.
src/libltfs/index_criteria.c
Outdated
| char rule[len+1], last, *ptr; | ||
|
|
||
| char *rule = NULL, last, *ptr; | ||
| int ruleLen = (sizeof(char) * (int)(len + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use camel case.
| int ruleLen = (sizeof(char) * (int)(len + 1)); | ||
| rule = (char*)calloc(ruleLen,sizeof(char)); | ||
| if (rule == NULL) { | ||
| return -LTFS_NO_MEMORY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message is needed.
| rulebuf = (char*)malloc(sizeof(char) * (len + 1)); | ||
| if (rulebuf == NULL) | ||
| { | ||
| return -LTFS_NO_MEMORY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message is needed.
|
Hmm, this PR has so many changes but no benefit to the original code users. Because they don't have any code built on windows even if your change is committed. Let me clarify how to progress.. I strongly recommend that you start over from scratch again. ObjectiveChange the code to be built on Visual C for the IBM product. But the tree cannot be built for this project. Directions
Changes Detail
|
chukero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
piste-jp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said multiple times, I cannot approve this at all.
- Number of commits are too many, please reduce number of commits . I cannot review the codes because GitHub is too slow because of excessive number of commits.
- Please minimize the changes of codes, please keep the original code as much as possible. If you want to remove warning and to make a refactoring, separate it from this PR.
- Please do not replace POSIX functions as
arch_prefixed functions. Windows is a POSIX approved OS, so there is no reason to rename this. - Please implement annex K functions on linux/Mac size if you really need to use them.
| #define arch_unlink unlink | ||
|
|
||
| #define arch_write write | ||
|
|
||
| #define arch_close close | ||
|
|
||
| #define arch_read read | ||
|
|
||
| #define arch_strdup strdup | ||
|
|
||
| #define arch_chmod chmod | ||
|
|
||
| #define arch_getpid getpid | ||
|
|
||
| #define arch_access access |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, Is arch_ prefix needed for POSIX functions ?
Remove lines in this #else block.
| #define arch_unlink _unlink | ||
|
|
||
| #define arch_write _write | ||
|
|
||
| #define arch_close _close | ||
|
|
||
| #define arch_read _read | ||
|
|
||
| #define arch_strdup _strdup | ||
|
|
||
| #define arch_chmod _chmod | ||
|
|
||
| #define arch_getpid _getpid | ||
|
|
||
| #define arch_access _access |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is arch_ prefix needed for POSIX functions?
Why not to use the code below.
#define unlink _unlink
#define write _write
#define close _close
#define read _read
#define strdup _strdup
#define chmod _chmod
#define getpid _getpid
#define access _access
Summary of changes
This pull request includes following changes or fixes.
Description
Code was updated to be compatible again with Windows platform. Microsoft mandates compilation with Microsoft tools to give support, with that said the code needed to be compatible with Microsoft Visual C++ Compiler for a new version to be built.
Macros we're added to comply with this and change the behavior depending on which platform the project is being built.
Type of change
Checklist: