Page MenuHomePhabricator

DerWaschbar (Beka Grdzelishvili)
User

Projects

User does not belong to any projects.

User Details

User Since
May 5 2020, 10:55 AM (64 w, 1 d)

Recent Activity

May 24 2020

DerWaschbar added a comment to D79437: [clang-tidy] Add fsetpos argument checker.

Thank you for working on this check, I think it's useful functionality. One concern I have, though, is that it's not flow-sensitive and should probably be implemented as a clang static analyzer check instead of a clang-tidy check. For instance, consider these three plausible issues:

// This only sets the offset on one code path.
void func(FILE *fp) {
  fpos_t offset;
  if (condition) {
    // ... code
    if (0 != fgetpos(fp, &offset))
      return;
    // ... code
  } else {
   // ... code
  }
  fsetpos(fp, &offset);
}

// This doesn't check the failure from getting the position and sets the position regardless.
void func(FILE *fp) {
  fpos_t offset;
  fgetpos(fp, &offset);
  // ... code
  fsetpos(fp, &offset);
}

// This function accepts the offset from the caller but the caller passes an invalid offset.
void func(FILE *fp, const fpos_t *offset) {
  fsetpos(fp, offset);
}
void caller(FILE *fp) {
  fpos_t offset;
  func(fp, &offset);
}

Have you considered writing a static analyzer check so you can do data and control flow analysis to catch issues like these?

May 24 2020, 11:44 AM · Restricted Project
DerWaschbar updated the diff for D79437: [clang-tidy] Add fsetpos argument checker.
May 24 2020, 8:32 AM · Restricted Project

May 19 2020

DerWaschbar updated the diff for D79437: [clang-tidy] Add fsetpos argument checker.

Rebased

May 19 2020, 9:48 AM · Restricted Project

May 6 2020

DerWaschbar added a comment to D79437: [clang-tidy] Add fsetpos argument checker.
May 6 2020, 8:35 AM · Restricted Project
DerWaschbar updated the diff for D79437: [clang-tidy] Add fsetpos argument checker.
  • Removed unnecessary empty lines.
  • Added double back-ticks to highlight language constructs.
  • Indented code in documentation.
May 6 2020, 8:35 AM · Restricted Project

May 5 2020

DerWaschbar created D79437: [clang-tidy] Add fsetpos argument checker.
May 5 2020, 11:20 AM · Restricted Project