-
Notifications
You must be signed in to change notification settings - Fork 84
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
base: v2.4-stable
Are you sure you want to change the base?
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)
...
#endif
See 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.
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.
@@ -1764,7 +1764,7 @@ ssize_t _unified_insert_new_request(const char *buf, off_t offset, size_t count, | |||
memcpy(cache_manager_get_object_data(*cache), buf, copy_count); | |||
|
|||
/* 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.
@@ -2325,7 +2325,7 @@ int unified_set_profiler(char *work_dir, bool enable, void *iosched_handle) | |||
return -LTFS_NO_MEMORY; | |||
} | |||
|
|||
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
|
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: