What does request_mem_region() actually do and when it is needed?

request_mem_region tells the kernel that your driver is going to use this range of I/O addresses, which will prevent other drivers to make any overlapping call to the same region through request_mem_region. This mechanism does not do any kind of mapping, it’s a pure reservation mechanism, which relies on the fact that all kernel device … Read more

Integer overflow in C: standards and compilers

Take a look at -ftrapv and -fwrapv: -ftrapv This option generates traps for signed overflow on addition, subtraction, multiplication operations. -fwrapv This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. This flag enables some optimizations and disables other. This option is enabled by … Read more

Why glibc’s fclose(NULL) cause segmentation fault instead of returning error?

fclose requires as its argument a FILE pointer obtained either by fopen, one of the standard streams stdin, stdout, or stderr, or in some other implementation-defined way. A null pointer is not one of these, so the behavior is undefined, just like fclose((FILE *)0xdeadbeef) would be. NULL is not special in C; aside from the … Read more

What are weak functions and what are their uses? I am using a stm32f429 micro controller

When a function is prepended with the descriptor __weak it basically means that if you (the coder) do not define it, it is defined here. Let us take a look at my arch-nemesis “HAL_UART_RxCpltCallback()”. This function exists within the HAL of the STM32F4-HAL code base that you can download from ST-Micro. Within the file stm32f4xx_hal_uart.c … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)