NAME
mv - move blog
SYNOPSIS
mv URL
DESCRIPTION
Blog was moved off blogger
SEE ALSO
https://blog.deschouwer.co.za/
AUTHOR
Berend De Schouwer
Discussions of valid abuse of malloc(0) in C on Linux.
NAME
mv - move blog
SYNOPSIS
mv URL
DESCRIPTION
Blog was moved off blogger
SEE ALSO
https://blog.deschouwer.co.za/
AUTHOR
Berend De Schouwer
select 'Mon May 11 11:21:31 SAST 2015'::date;This works, but only for some timezones:
select 'Mon May 11 11:21:31 CAT 2015'::date; ERROR: invalid input syntax for type date: "Mon May 11 11:21:31 CAT 2015" LINE 1: select 'Mon May 11 11:21:31 CAT 2015'::date ;CAT is unknown.
The problem is caused by a peculiar characteristic of C: char is machine specific. char can be signed or unsigned, depending on the processor.char c = -1 // -1; int i = c // -1; call_something(i /* -1 */);
The difference is because C auto-promotes signed char to signed int, and unsigned char to signed int.char c = -1; // 255 int i = c; // 255 call_something(i /* 255 */);
#includevoid foo(char *fmt, ...){ va_list ap; va_start(ap, fmt); int i = va_arg(ap, int); ... va_end(ap); }
void foo(char *fmt, int i){ }
However, it will auto-promote chars. You cannot use va_arg(ap, char). va_list and friends are macros. So you have to be very careful if you think you'll grab all instances of char.
AC_C_CHAR_UNSIGNED
if test $ac_cv_c_char_unsigned = yes && test "$GCC" = yes; then
CFLAGS+=" -fsigned-char "
fi
// list of strings
char * list[] = {
"apple",
"pear",
NULL
}
char ** s;
for (s = list; *s; ++s) {
printf("%s\n", *s);
}
if (malloc(-1) == NULL) return (-1);
// list of strings
char * list[] = {
"apple",
"pear",
NULL,
"banana",
NULL
}
we'd never get to "banana". We'd never free it. There would be a memory leak.
char * list[] = {
"apple",
"pear",
(void *)-1,
"banana",
NULL
}
Now we can check for (void *)-1 to know that the list isn't finished (not NULL), but that the contents at this index are uninitialized.
Implementing central authentication with password expiry on systems that implement NSS is actually broken.
if [ -r /home/berend.deschouwer/.gnupg/gpg-agent-hostname ]; then . .gnupg/gpg-agent-info-hostname export GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID fi
export DISPLAY=:0.0 gnome-shell --replace &