thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Geyer (Jira)" <j...@apache.org>
Subject [jira] [Comment Edited] (THRIFT-4940) value should inialization when defined
Date Tue, 27 Aug 2019 22:05:00 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4940?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16917151#comment-16917151
] 

Jens Geyer edited comment on THRIFT-4940 at 8/27/19 10:04 PM:
--------------------------------------------------------------

GetFullPathName() will set the values on success and the caller is advised to not use the
values on error return. This is a common Windows API pattern, I don't think adding any initialisation
code will improve anything. Thou shalt not use invalid data, period. 

Only "maybe" point of discussion here is the basename argument, as this one is documented
as "can be NULL" and it is not used anyway. OTOH, never change a running system unless you
have a good reason ...




was (Author: jensg):
GetFullPathName() will set the values on success and the caller is advised to not use the
values on error return. This is a common Windows API pattern, I don't think adding any initialisation
code will improve anything. Thou shalt not use invalid data, period. 

Only "maybe" point of discussion here is the basename argument, as this one is documented
as "can be NULL" and it is not used anyway. OTOHJ, never change a running system unless you
have a good reason ...



> value should inialization when defined
> --------------------------------------
>
>                 Key: THRIFT-4940
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4940
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.13.0
>         Environment: win7, visual studio 2015, thrift-master
>            Reporter: pengzhouhu
>            Priority: Trivial
>             Fix For: 0.13.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
>  i debug the compiler in compiler\cpp\src\thrift\generate\main.cc   line 169, values
should inialization before beused. a little improvement i suggest. 
> {code:c++}
> /**
>  * Win32 doesn't have realpath, so use fallback implementation in that case,
>  * otherwise this just calls through to realpath
>  */
> char* saferealpath(const char* path, char* resolved_path) {
> #ifdef _WIN32
>   char buf[MAX_PATH];
>   char* basename;
>   DWORD len = GetFullPathNameA(path, MAX_PATH, buf, &basename);
>   if (len == 0 || len > MAX_PATH - 1) {
>     strcpy(resolved_path, path);
>   } else {
>     strcpy(resolved_path, buf);
>   }
>   // Replace backslashes with forward slashes so the
>   // rest of the code behaves correctly.
>   size_t resolved_len = strlen(resolved_path);
>   for (size_t i = 0; i < resolved_len; i++) {
>     if (resolved_path[i] == '\\') {
>       resolved_path[i] = '/';
>     }
>   }
>   return resolved_path;
> #else
>   return realpath(path, resolved_path);
> #endif
> }
> {code}
> thanks.
> zhouhu.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Mime
View raw message