[
https://issues.apache.org/jira/browse/HDFS-3916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13458304#comment-13458304
]
Andy Isaacson commented on HDFS-3916:
-------------------------------------
Thanks for the cleanups, Colin!
The test failures are unrelated.
{code}
+static void dotsToSlashes(char *str)
+{
+ while (1) {
+ char c = *str;
+ if (c == '\0')
+ return;
+ if (c == '.')
+ c = '/';
+ str++;
+ }
{code}
We can avoid the unnecessary local variable with the idiomatic
{code}
for (;*str != '\0'; str++) {
if (*str == '.')
*str = '/';
}
{code}
+ * Working directory -- stored without a trailing slash.
+ */
+ char *workingDir;
...
...
+ snprintf(absPath, absPathLen + 1, "%s%s", fs->workingDir, path);
{code}
Either the comment or the format string is wrong.
{code}
+ newWorkingDir = malloc(strlenPath + 1);
...
+ snprintf(newWorkingDir, strlenPath + 2, "%s%s",
{code}
the malloc is one byte short, it should be +2 as well. I'd make an explicit
target-size variable rather than repeating this computation (which leads to
bugs, as we see).
> libwebhdfs (C client) code cleanups
> -----------------------------------
>
> Key: HDFS-3916
> URL: https://issues.apache.org/jira/browse/HDFS-3916
> Project: Hadoop HDFS
> Issue Type: Bug
> Components: webhdfs
> Affects Versions: 3.0.0
> Reporter: Colin Patrick McCabe
> Assignee: Colin Patrick McCabe
> Attachments: 0002-fix.patch, HDFS-3916.003.patch,
> HDFS-3916.004.patch, HDFS-3916.005.patch
>
>
> Code cleanups in libwebhdfs.
> * don't duplicate exception.c, exception.h, expect.h, jni_helper.c. We have
> one copy of these files; we don't need 2.
> * remember to set errno in all public library functions (this is part of the
> API)
> * fix undefined symbols (if a function is not implemented, it should return
> ENOTSUP, but still exist)
> * don't expose private data structures in the (end-user visible) public
> headers
> * can't re-use hdfsBuilder as hdfsFS, because the strings in hdfsBuilder are
> not dynamically allocated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira