Skip to content
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

ftplib::Pwd - useless postincrement causes unwanted warning #15

Open
Fojtik opened this issue Dec 1, 2016 · 0 comments
Open

ftplib::Pwd - useless postincrement causes unwanted warning #15

Fojtik opened this issue Dec 1, 2016 · 0 comments

Comments

@Fojtik
Copy link

Fojtik commented Dec 1, 2016

*
 * FtpPwd - get working directory at remote
 *
 * return 1 if successful, 0 otherwise
 */
int ftplib::Pwd(char *path, int max)
{
  int l = max;
  char *b = path;
  char *s;

   if (!FtpSendCmd("PWD",'2',mp_ftphandle)) return 0;
  s = strchr(mp_ftphandle->response, '"');
  if (s == NULL) return 0;
   s++;
  while ((--l) && (*s) && (*s != '"')) *b++ = *s++;
  *b++ = '\0';  // !!!! This causes a warning
  return 1;
}

Proposed fix:

*
 * FtpPwd - get working directory at remote
 *
 * return 1 if successful, 0 otherwise
 */
int ftplib::Pwd(char *path, int max)
{
  int l = max;
  char *b = path;
  char *s;

   if (!FtpSendCmd("PWD",'2',mp_ftphandle)) return 0;
  s = strchr(mp_ftphandle->response, '"');
  if (s == NULL) return 0;
   s++;
  while ((--l) && (*s) && (*s != '"')) *b++ = *s++;
  *b = '\0';
  return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant