[ros-dev] [ros-diffs] [akhaldi] 54136: [CMD] * Reduce the scope of some variables.
Minas Abrahamyan
minas.subs at gmail.com
Fri Oct 14 21:35:51 UTC 2011
Because The Rule of:
========================================
Program Code Should be _Locally_Understandable_.
========================================
And this PoV changes a lot of things.
What does produce Software Engineer (AKA computer programmer)? Does he
produce software code?
No. He only do achieve high level of *understanding* of preexisting
code or newly generated idea, and from this position forth now
produces new implementations and/or *new levels of understanding*,
written occasionally as program code.
Since followers always doomed to read the code to get required level
of understanding, making code more readable is good.
Regarding to standards, I don't believe ROS coding style guide forbids
such kinds of code as being more understandable.
This is not inherent to ROS standard.
WBR,
M.A.
On Sat, Oct 15, 2011 at 1:54 AM, Alex Ionescu <ionucu at videotron.ca> wrote:
> Why?
> It doesn't change anything...and...
>
> This is not our coding standard.
> Best regards,
> Alex Ionescu
>
>
> On Fri, Oct 14, 2011 at 1:50 PM, <akhaldi at svn.reactos.org> wrote:
>>
>> Author: akhaldi
>> Date: Fri Oct 14 17:50:16 2011
>> New Revision: 54136
>>
>> URL: http://svn.reactos.org/svn/reactos?rev=54136&view=rev
>> Log:
>> [CMD]
>> * Reduce the scope of some variables.
>>
>> Modified:
>> trunk/reactos/base/shell/cmd/assoc.c
>> trunk/reactos/base/shell/cmd/dir.c
>> trunk/reactos/base/shell/cmd/filecomp.c
>> trunk/reactos/base/shell/cmd/start.c
>> trunk/reactos/base/shell/cmd/ver.c
>>
>> Modified: trunk/reactos/base/shell/cmd/assoc.c
>> URL:
>> http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/assoc.c?rev=54136&r1=54135&r2=54136&view=diff
>>
>> ==============================================================================
>> --- trunk/reactos/base/shell/cmd/assoc.c [iso-8859-1] (original)
>> +++ trunk/reactos/base/shell/cmd/assoc.c [iso-8859-1] Fri Oct 14 17:50:16
>> 2011
>> @@ -206,8 +206,6 @@
>> INT CommandAssoc (LPTSTR param)
>> {
>>
>> - LPTSTR lpEqualSign = NULL;
>> -
>> /* print help */
>> if (!_tcsncmp (param, _T("/?"), 2))
>> {
>> @@ -221,7 +219,7 @@
>> PrintAllAssociations();
>> else
>> {
>> - lpEqualSign = _tcschr(param, _T('='));
>> + LPTSTR lpEqualSign = _tcschr(param, _T('='));
>> if(lpEqualSign != NULL)
>> {
>> LPTSTR fileType = lpEqualSign + 1;
>>
>> Modified: trunk/reactos/base/shell/cmd/dir.c
>> URL:
>> http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/dir.c?rev=54136&r1=54135&r2=54136&view=diff
>>
>> ==============================================================================
>> --- trunk/reactos/base/shell/cmd/dir.c [iso-8859-1] (original)
>> +++ trunk/reactos/base/shell/cmd/dir.c [iso-8859-1] Fri Oct 14 17:50:16
>> 2011
>> @@ -1260,13 +1260,11 @@
>> LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags that
>> we will use to sort */
>> {
>> LPWIN32_FIND_DATA lpTemp; /* A temporary pointer */
>> - int First, Last, Temp;
>> BOOL Way;
>>
>> if (i < j)
>> {
>> - First = i;
>> - Last = j;
>> + int First = i, Last = j, Temp;
>> Way = TRUE;
>> while (i != j)
>> {
>>
>> Modified: trunk/reactos/base/shell/cmd/filecomp.c
>> URL:
>> http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/filecomp.c?rev=54136&r1=54135&r2=54136&view=diff
>>
>> ==============================================================================
>> --- trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] (original)
>> +++ trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] Fri Oct 14
>> 17:50:16 2011
>> @@ -209,7 +209,6 @@
>> TCHAR path[MAX_PATH];
>> TCHAR fname[MAX_PATH];
>> TCHAR directory[MAX_PATH];
>> - UINT longestfname = 0;
>> SHORT screenwidth;
>>
>> /* expand current file name */
>> @@ -277,6 +276,7 @@
>> hFile = FindFirstFile (path, &file);
>> if (hFile != INVALID_HANDLE_VALUE)
>> {
>> + UINT longestfname = 0;
>> /* Get the size of longest filename first. */
>> do
>> {
>>
>> Modified: trunk/reactos/base/shell/cmd/start.c
>> URL:
>> http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/start.c?rev=54136&r1=54135&r2=54136&view=diff
>>
>> ==============================================================================
>> --- trunk/reactos/base/shell/cmd/start.c [iso-8859-1] (original)
>> +++ trunk/reactos/base/shell/cmd/start.c [iso-8859-1] Fri Oct 14 17:50:16
>> 2011
>> @@ -48,7 +48,6 @@
>> TCHAR szFullCmdLine [CMDLINE_LENGTH];
>> PROCESS_INFORMATION prci;
>> STARTUPINFO stui;
>> - INT i = 0;
>> #ifdef UNICODE
>> DWORD dwCreationFlags = CREATE_NEW_CONSOLE |
>> CREATE_UNICODE_ENVIRONMENT;
>> #else
>> @@ -213,7 +212,7 @@
>> /* Parsing the command that gets called by start, and it's
>> parameters */
>> {
>> BOOL bInside = FALSE;
>> -
>> + INT i;
>> /* find the end of the command and put the arguments in
>> param */
>> for (i = 0; Rest[i]; i++)
>> {
>>
>> Modified: trunk/reactos/base/shell/cmd/ver.c
>> URL:
>> http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/ver.c?rev=54136&r1=54135&r2=54136&view=diff
>>
>> ==============================================================================
>> --- trunk/reactos/base/shell/cmd/ver.c [iso-8859-1] (original)
>> +++ trunk/reactos/base/shell/cmd/ver.c [iso-8859-1] Fri Oct 14 17:50:16
>> 2011
>> @@ -28,8 +28,6 @@
>> VOID ShortVersion (VOID)
>> {
>> OSVERSIONINFO VersionInfo;
>> - unsigned RosVersionLen;
>> - LPTSTR RosVersion;
>>
>> ConOutResPrintf(STRING_CMD_SHELLINFO, _T(KERNEL_RELEASE_STR),
>> _T(KERNEL_VERSION_BUILD_STR));
>> VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
>> @@ -37,6 +35,9 @@
>> memset(VersionInfo.szCSDVersion, 0,
>> sizeof(VersionInfo.szCSDVersion));
>> if (GetVersionEx(&VersionInfo))
>> {
>> + LPTSTR RosVersion;
>> + unsigned RosVersionLen;
>> +
>> RosVersion = VersionInfo.szCSDVersion +
>> _tcslen(VersionInfo.szCSDVersion) + 1;
>> RosVersionLen = sizeof(VersionInfo.szCSDVersion) /
>> sizeof(VersionInfo.szCSDVersion[0]) -
>> (RosVersion - VersionInfo.szCSDVersion);
>>
>>
>
>
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev
>
More information about the Ros-dev
mailing list