CABMAN: Remove _WIN32 ifdef's#252
Conversation
|
Hi, please squash your first two commits and fix your author/committer's name! |
| /* | ||
| * COPYRIGHT: See COPYING in the top level directory | ||
| * PROJECT: ReactOS cabinet manager | ||
| * FILE tools/cabman/CCFDATAStorageWindows.cxx |
There was a problem hiding this comment.
The file name does not correspond to the actual one.
There was a problem hiding this comment.
Thank you for your comments, I changed headers of the two files I've added.
| * PROGRAMMERS: | ||
| * NOTES: | ||
| * REVISIONS: | ||
| */ |
There was a problem hiding this comment.
The header file does not seem to meet the actual ReactOS Coding Style standard if I am not mistaken. NOTES and REVISIONS are unnecessary. Please refer to this article (File Structure) regarding this.
| * COPYRIGHT: See COPYING in the top level directory | ||
| * PROJECT: ReactOS cabinet manager | ||
| * FILE tools/cabman/CCFDATAStorageWindows.cxx | ||
| * PURPOSE: CCFDATAStorage class implementation for Windows |
| */ | ||
| { | ||
| fclose(FileHandle); | ||
| FileHandle = tmpfile(); |
There was a problem hiding this comment.
Why such a complex implementation?
Why not using ftruncate(fileno(FileHandle), 0); ?
And likely fseek(FileHandle, 0, SEEK_SET); beforehand.
There was a problem hiding this comment.
Agree that this is not an optimal implementation, but current task is only to remove _WIN32, so I just left the implementation itself untouched.
Refactoring could be the next step.
| LONG size; | ||
| fseek(handle, 0, SEEK_END); | ||
| size = ftell(handle); | ||
| fseek(handle, 0, SEEK_SET); |
There was a problem hiding this comment.
I'm a bit skeptical about this... Wouldn't it be better to save current position, query for full size, and restore saved position?
So that, it would be consistent with Win32 behaviour.
There was a problem hiding this comment.
Indeed, the call to fseek() in line 113 looks strange. But currently I'm trying to not mix tasks together, so I kept the implementation untouched only removing _WIN32 ifdef's.
| * Copyright 2017 Colin Finck <mail@colinfinck.de> | ||
| * Copyright 2018 Dmitry Bagdanov <dimbo_job@mail.ru> | ||
| */ | ||
| #if !defined(_WIN32) |
There was a problem hiding this comment.
So... this really isn't so much a Unix implementation as it is a standard C library one. Why don't we just delete the Win32 version and use this across the board? (I think that may have been the intent behind the Jira ticket)
There was a problem hiding this comment.
I thought about that ;)
But then I decided to keep the initial intention to not use standard C library file access functions on Windows...
There was a problem hiding this comment.
The idea was indeed to drop the win32 one,
since it looks like the other stuff was written after the win32 one.
There was a problem hiding this comment.
Well that will be the next pull request then.
There was a problem hiding this comment.
The problem with that approach is that what you propose now is not a natural step between the current version of the code and where we'd probably want it to be. E.g. changing if-CreateFile-else-fopen to fopen is much more straightforward than changing it to OpenFileForReading, and then back to the fopen that was already there before. That just seems like unnecessary code churn.
I'm open to discussion, but right now it seems to me like literally deleting all the stuff in the _WIN32 code path would get us closest to where we want to be.
There was a problem hiding this comment.
ThFabba, now I'm completely agree with you. That was my misunderstanding that the intention is to not use standard C file access functions on Windows. So I'm going to provide another pull request that uses standard C functions on all platforms.
There was a problem hiding this comment.
@dfbag7 For reference, if you push commits to the same branch they will end up in this pull request.
If you rewrite this branches history and then force-push you will update this pull request.
There was a problem hiding this comment.
Otherwise, as the intent is totally different from original idea, perhaps should we close that PR for a brand new one? New code, new direction, new PR? :-)
There was a problem hiding this comment.
Whatever the process here is - I'm fine with either updating or creating a new PR - I conclude this is WIP, so I'll add the WIP tag.
There was a problem hiding this comment.
@dfbag7 Can you please make a basic performance evaluation after your changes? I am asking because I have experienced (mainly with STL) that portable code can lead to heavily degrading performance and this tool is already kinda slow, so I wouldn't want it to become even slower.
|
@dfbag7 Thanks for working on this! This tool really needs some love. |
|
Hi,
I have done some testing and found that using native WIN32 functions for
file access does not give any notable performance gain, so I'm going to
remove all WIN32 native code in favor of stdio.
Probably using STL will be the next step, thank you for the suggestion.
…On 11.01.2018 23:36, Colin Finck wrote:
@dfbag7 <https://github.com/dfbag7> Thanks for working on this! This
tool really needs some love.
While you're converting things to C++ classes/STL, you may also want
to save some code by replacing my SEARCH_CRITERIA structure by an
std::vector. I added that and some custom linked-list code years ago
when I was still lacking STL proficiency..
Apart from that, I'm all for dropping the Win32-only code pathes and
using STL for file access (alternatively stdio if that gives a better
performance).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#252 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFndVKUKFz5bOQyzjs4L59WUmtvjVuavks5tJjiDgaJpZM4RQGXs>.
|
|
In my experience moving fromg stdio to STL will incur a performance hit. |
|
I'm guessing it's the processing, not the file I/O that makes cabman slow though? |
|
Yes. I have not done profiling, but almost sure that the I/O does not affect performance as much as zipping (which is actually performed by ZLIB library). |
|
Hi all, |
learn-more
left a comment
There was a problem hiding this comment.
Hello @dfbag7, sorry for the late reply.
Overall this is already very good looking, I have added some inline comments about some details.
sdk/tools/cabman/CCFDATAStorage.cxx
Outdated
| CCFDATAStorage::CCFDATAStorage() | ||
| /* | ||
| * FUNCTION: Default constructor | ||
| */ |
There was a problem hiding this comment.
If you want to use per-function comments, please stick to a format that is doxygen compatible, preferrably the one outlined here:
https://reactos.org/wiki/Coding_Style
There was a problem hiding this comment.
The whole CABMAN project uses that style of function comments, so decided to not change them to maintain consistency.
Now the comments changed to the reactos' standard (only in file CCFDATAStorage.cxx file, though).
Commit fc99634
sdk/tools/cabman/CCFDATAStorage.cxx
Outdated
| DPRINT(MID_TRACE, ("ERROR '%i'.\n", errno)); | ||
| return CAB_STATUS_CANNOT_CREATE; | ||
| } | ||
| */ |
There was a problem hiding this comment.
Those code was left from initial implementation, and I considered to not remove it...
Removed in commit 753efbe
sdk/tools/cabman/CCFDATAStorage.cxx
Outdated
| } | ||
| */ | ||
|
|
||
| FileCreated = true; |
There was a problem hiding this comment.
I think you can remove FileCreated alltogether, and just check on FileHandle != NULL ?
sdk/tools/cabman/cabinet.h
Outdated
| #define DIR_SEPARATOR_CHAR '\\' | ||
| #define DIR_SEPARATOR_STRING "\\" | ||
| #define DIR_SEPARATOR_CHAR '\\' | ||
| #define DIR_SEPARATOR_STRING "\\" |
There was a problem hiding this comment.
For what it's worth, we seem to have three indentation styles for preprocessor directives in use throughout the codebase:
- No indentation at all
- Indenting like @dfbag7 did
- Indenting the directive but not the hash (e.g. "# define")
I personally prefer the style @dfbag7 used. As our Coding Style guidelines give no rule regarding that, I use it myself in some modules.
However, it's up to you guys what shall be used for cabman in the future.
HeisSpiter
left a comment
There was a problem hiding this comment.
This new iteration looks good to me, I approve a squash & merge.
This will open room for improvement in the implementation :-).
|
Things look good on a cursory glance, but please make this at least 2 commits when merging. Moving existing code to a different file should always be its own commit, then changes to that code should be a second one. |
|
Perfect, thank you! |
CORE-12645
Purpose
JIRA issue: CORE-12645
Proposed changes
Basically I tried to remove as much as possible _WIN32 ifdef's to make the code easier to maintain. To achieve that, I did the following changes:
TODO
I tested the resulting code trying to create Hybrid CD in three environments:
Then I installed ReactOS from the resulting ISO image into VMWare VM. All worked fine.
There are, however, some ways to further polish the code. In particular, the code that chooses if existing target file should be overwritten when opening file for writing is still contains two ifdef'ed branches.