• 1 Post
  • 255 Comments
Joined 2 years ago
cake
Cake day: July 3rd, 2023

help-circle
  • printf is superior and more concise, and snprintf is practically the only C string manipulation function that is not painful to use.

    Try to print a 32-bit unsigned int as hexadecimal number of exactly 8 digits, using cout. You can do std::hex and std::setw(8) and std::setfill('0') and don’t forget to use std::dec afterwards, or you can just, you know, printf("%08x") like a sane person.

    Just don’t forget to use -Werror=format but that is the default option on many compilers today.

    C++23 now includes std::print which is exactly like printf but better, so the whole argument is over.











  • We want to inhibit when running stuff like pacman, wget, cp or mv

    There is already a separate systemd-inhibit command that does exactly what you need. Trust your users, they are capable of googling it (most of the time).

    Only pacman and wget will benefit from suspend inhibition, because it will prevent breaking network connections. cp and mv will resume working just fine even when you hibernated your laptop while cp was executing. And in that case it’s less bug-prone to scan your system for active TCP connections to external addresses instead of adding a hack wakelock inside your terminal or inside wget.

    It is also a poor idea to mess up with system-wide settings from some command when the user does not expect it, you’ll likely to get a thousand invalid bug reports that sleep mode is broken when some service randomly decides to use wget to continuously read from local Unix socket.






  • Anyway, having direct unprivileged R/W access to platform memory is indeed a security hole, no matter the vendor.

    It is not. ESP32 is an embedded chip with less than one megabyte of RAM. It cannot run apps or load websites with any malicious code, it only runs the firmware that you flash on it, nothing else, and of course your firmware has full access to every chip feature. If your firmware has a security hole, it’s not the chip’s fault.