Re: [dev] Some direction with my project

From: NRK <>
Date: Fri, 15 Apr 2022 19:25:38 +0600

Hi Dorian,

Took a quick glance into the source and a couple things which stood out,
that haven't been pointed out already:


Macros like this pretty much always should be parenthesized. It costs
nothing and can save you from getting into potential bugs. See for a more detailed explanation.

        else if (strlen(temp) > 0) {
          strcat(tempForWrite, temp);

I see lots of `strcat` calls going on, and maybe you *are* checking for
overflow somewhere out there, but it's not immediately obvious where.

I would suggest using `strlcat` instead. I would also suggest being very
careful with the str* family of functions, they often contain various
bear traps.

          if (errno == ENOTSUP) {
              fprintf(stderr, "Extended attributes are not available on your filesystem.\n");
              return -1;
            } else if (errno == ENOENT) {
              fprintf(stderr, "File does not exist.\n");
              return -1;

Use strerror().
Also a lot of these messages are being used in multiple location. I'd
just use a macro for them.

        #define ERRMSG_X "error x"
        fprintf(stderr, "%s\n", ERRMSG_X);

...Or an array of them and index into it using enum.

Lastly, it's already been pointed out, but it's very cringe having to go
into a `src` dir just to find a single source file in there.

And related to that, given it's a single source file and none of the
functions are being called externally, you should declare (as well as
define) all the functions as `static`.

Received on Fri Apr 15 2022 - 15:25:38 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 15 2022 - 15:36:07 CEST