Skip to content

Commit

Permalink
Use sizeof()
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jan 19, 2023
1 parent 1d9087c commit 095b45b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ extern "C" {
while (it.Next(&start, &end, &flags, &offset, &inode, &filename)) {
char buffer[17];

snprintf(buffer, 17, "%016" PRIx64, start);
snprintf(buffer, sizeof(buffer), "%016" PRIx64, start);
cb(data, row, 0, total_rows, buffer);

snprintf(buffer, 17, "%016" PRIx64, end);
snprintf(buffer, sizeof(buffer), "%016" PRIx64, end);
cb(data, row, 1, total_rows, buffer);

// We assume 'flags' looks like 'rwxp' or 'rwx'.
Expand All @@ -49,13 +49,13 @@ extern "C" {
// p always seems set on linux, so we set the default to 'p', not '-'
char p = (flags && flags[0] && flags[1] && flags[2] && flags[3] != 'p')
? '-' : 'p';
snprintf(buffer, sizeof(char) * 4 + 1, "%c%c%c%c", r, w, x, p);
snprintf(buffer, sizeof(buffer), "%c%c%c%c", r, w, x, p);
cb(data, row, 2, total_rows, buffer);

snprintf(buffer, sizeof(uint64) + 1, "%08" PRIx64, offset);
snprintf(buffer, sizeof(buffer), "%08" PRIx64, offset);
cb(data, row, 3, total_rows, buffer);

snprintf(buffer, sizeof(int64) + 1, "%" PRId64, inode);
snprintf(buffer, sizeof(buffer), "%" PRId64, inode);
cb(data, row, 4, total_rows, buffer);

cb(data, row, 5, total_rows, filename);
Expand Down

0 comments on commit 095b45b

Please sign in to comment.