klange / toaruos

A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
https://toaruos.org/
University of Illinois/NCSA Open Source License
6.03k stars 475 forks source link

int errno = 0; int errno; has been changed to. #291

Closed LinuxUsersLinuxMint closed 7 months ago

LinuxUsersLinuxMint commented 7 months ago

Every integer (int) value created in the C programming language is 0 by default, so "int errno = 0;" This code is unnecessary, instead int errno; I changed it to.

klange commented 7 months ago
  1. I do not accept pull requests without prior discussion.
  2. This use of an explicit initializer is a stylistic choice used to indicate to readers that the value of 0 is intentional and the variable is not expected to be otherwise set by initialization code elsewhere.
zecarlos1957 commented 7 months ago

If I remember correctly, if it is a local variable (which resides on the stack) this memory location will not be cleaned, and the last value used at that address will persist. Only the global and static variables that reside in the memory assigned to the program will be reset.