Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: fusl/src/stdio/tempnam.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fusl/src/stdio/tempnam.c
diff --git a/fusl/src/stdio/tempnam.c b/fusl/src/stdio/tempnam.c
index 5a5597527c0851d5d2c45fff1c6f1e2459e81375..57f557ddabbb34e6704969d0a86f0a2e918cf12f 100644
--- a/fusl/src/stdio/tempnam.c
+++ b/fusl/src/stdio/tempnam.c
@@ -8,42 +8,45 @@
#define MAXTRIES 100
-char *__randname(char *);
-
-char *tempnam(const char *dir, const char *pfx)
-{
- char s[PATH_MAX];
- size_t l, dl, pl;
- int try;
- int r;
-
- if (!dir) dir = P_tmpdir;
- if (!pfx) pfx = "temp";
-
- dl = strlen(dir);
- pl = strlen(pfx);
- l = dl + 1 + pl + 1 + 6;
-
- if (l >= PATH_MAX) {
- errno = ENAMETOOLONG;
- return 0;
- }
-
- memcpy(s, dir, dl);
- s[dl] = '/';
- memcpy(s+dl+1, pfx, pl);
- s[dl+1+pl] = '_';
- s[l] = 0;
-
- for (try=0; try<MAXTRIES; try++) {
- __randname(s+l-6);
+char* __randname(char*);
+
+char* tempnam(const char* dir, const char* pfx) {
+ char s[PATH_MAX];
+ size_t l, dl, pl;
+ int try
+ ;
+ int r;
+
+ if (!dir)
+ dir = P_tmpdir;
+ if (!pfx)
+ pfx = "temp";
+
+ dl = strlen(dir);
+ pl = strlen(pfx);
+ l = dl + 1 + pl + 1 + 6;
+
+ if (l >= PATH_MAX) {
+ errno = ENAMETOOLONG;
+ return 0;
+ }
+
+ memcpy(s, dir, dl);
+ s[dl] = '/';
+ memcpy(s + dl + 1, pfx, pl);
+ s[dl + 1 + pl] = '_';
+ s[l] = 0;
+
+ for (try = 0; try < MAXTRIES; try ++) {
+ __randname(s + l - 6);
#ifdef SYS_lstat
- r = __syscall(SYS_lstat, s, &(struct stat){0});
+ r = __syscall(SYS_lstat, s, &(struct stat){0});
#else
- r = __syscall(SYS_fstatat, AT_FDCWD, s,
- &(struct stat){0}, AT_SYMLINK_NOFOLLOW);
+ r = __syscall(SYS_fstatat, AT_FDCWD, s, &(struct stat){0},
+ AT_SYMLINK_NOFOLLOW);
#endif
- if (r == -ENOENT) return strdup(s);
- }
- return 0;
+ if (r == -ENOENT)
+ return strdup(s);
+ }
+ return 0;
}

Powered by Google App Engine
This is Rietveld 408576698