stdio: conversion specifiers should immediately follow length modifiers
[neatlibc.git] / mkstemp.c
blob4173b9daa1ae3d31c142a54de89c4f3102531e7f
1 #include <fcntl.h>
2 #include <string.h>
4 static int tmpid;
5 static char *digs = "0123456789abcdef";
7 int mkstemp(char *t)
9 char *x = t + strlen(t) - 6;
10 int fd;
11 int i;
12 if (strlen(t) < 6)
13 return -1;
14 for (i = 0; i < 6; i++)
15 x[i] = '0';
16 while ((fd = open(t, O_RDWR | O_EXCL | O_CREAT, 0600)) == -1) {
17 int n = ++tmpid;
18 for (i = 0; i < 6; i++) {
19 x[5 - i] = digs[n & 0x0f];
20 n <<= 4;
23 unlink(t);
24 return fd;