/* * I'm tired of doing "vsnprintf()" etc just to open a * file, so here's a "return static buffer with printf" * interface for paths. * * It's obviously not thread-safe. Sue me. But it's quite * useful for doing things like * * f = open(mkpath("%s/%s.perf", base, name), O_RDONLY); * * which is what it's designed for. */ #include "cache.h" #include "util.h" #include static char bad_path[] = "/bad-path/"; /* * One hack: */ static char *get_pathname(void) { static char pathname_array[4][PATH_MAX]; static int idx; return pathname_array[3 & ++idx]; } static char *cleanup_path(char *path) { /* Clean it up */ if (!memcmp(path, "./", 2)) { path += 2; while (*path == '/') path++; } return path; } char *mkpath(const char *fmt, ...) { va_list args; unsigned len; char *pathname = get_pathname(); va_start(args, fmt); len = vsnprintf(pathname, PATH_MAX, fmt, args); va_end(args); if (len >= PATH_MAX) return bad_path; return cleanup_path(pathname); } 218e4c9276b0bac0545e5184c1c47b'/> net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
path: root/sound/pci/echoaudio/echoaudio_3g.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-02-07 16:29:30 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-07 16:29:30 -0500
commit3efa70d78f218e4c9276b0bac0545e5184c1c47b (patch)
treef4abe2f05e173023d2a262afd4aebb1e89fe6985 /sound/pci/echoaudio/echoaudio_3g.c
parent76e0e70e6452b971a69cc9794ff4a6715c11f7f2 (diff)
parent926af6273fc683cd98cd0ce7bf0d04a02eed6742 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
The conflict was an interaction between a bug fix in the netvsc driver in 'net' and an optimization of the RX path in 'net-next'. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'sound/pci/echoaudio/echoaudio_3g.c')