getopt: fix null pointer arithmetic ub
[musl] / src / temp / __randname.c
1 #include <time.h>
2 #include <stdint.h>
3 #include "pthread_impl.h"
4
5 /* This assumes that a check for the
6    template size has already been made */
7 char *__randname(char *template)
8 {
9         int i;
10         struct timespec ts;
11         unsigned long r;
12
13         __clock_gettime(CLOCK_REALTIME, &ts);
14         r = ts.tv_sec + ts.tv_nsec + __pthread_self()->tid * 65537UL;
15         for (i=0; i<6; i++, r>>=5)
16                 template[i] = 'A'+(r&15)+(r&16)*2;
17
18         return template;
19 }