News for hackers. Stuff that matters.
Re:A bug story: data alignment in C on x86 (2016) by caf on Tuesday September 04, 2018 @10:02PM (#17914547)
You don't actually need a cast to write a qsort comparison function, because void * is implicitly converted to and from other pointer types in C. Eg:

  int compare_xyzzy(const void *a, const void *b)
  {
      const struct xyzzy *sa = a;
      const struct xyzzy *sb = b;

      return (sa->i > sb->i) - (sa->i < sb->i);
  }
On the other hand, pointer casts are needed if you want to write a function like strchr() (where you can pass a const-qualified pointer, but want to return an unqualified pointer for the case where an unqualified pointer was passed).
Re:A bug story: data alignment in C on x86 (2016) by saagarjha on Wednesday September 05, 2018 @02:25AM (#17915485)
D'oh! You're right, of course.