kmod-project / kmod

kmod - Linux kernel module handling
GNU Lesser General Public License v2.1
40 stars 34 forks source link

depmod: Remove NOFAIL usage #130

Closed stoeckmann closed 2 weeks ago

stoeckmann commented 3 weeks ago

Split off from https://github.com/kmod-project/kmod/pull/123

Removes the unimplemented NOFAIL macro from depmod and adds another strdup NULL check.

evelikov commented 3 weeks ago

If we're going the allocations-cannot-fail route, I would suggest having "x" helpers, like the following example from gcc docs

// NB: should probably make a macro for the attribute
char *xstrdup (const char *)
  __attribute__((malloc (free), returns_nonnull));

Perhaps one can follow them with a macro like below, so any instances get automatically converted. I'd refer whether we want this to @lucasdemarchi though.

#define strdup xstrdup
lucasdemarchi commented 2 weeks ago

Not a fan of overriding the libc functions like that. Let's go with this version. Thanks

evelikov commented 2 weeks ago

IMHO one important drawback of mixing "allocation can fail" and "cannot fail" logic is that one needs to re-review them every time they make changes to the code base.