Skip to content

Commit

Permalink
Merge pull request #2365 from brauner/2018-05-30/improve_strprint
Browse files Browse the repository at this point in the history
confile: improve strprint()
  • Loading branch information
stgraber committed May 30, 2018
2 parents 9715e65 + 9496659 commit ed40d79
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/lxc/confile_utils.h
Expand Up @@ -41,21 +41,24 @@
#define MACVLAN_MODE_PASSTHRU 8
#endif

#define strprint(str, inlen, ...) \
do { \
len = snprintf(str, inlen, ##__VA_ARGS__); \
if (len < 0) { \
SYSERROR("failed to create string"); \
return -1; \
}; \
fulllen += len; \
if (inlen > 0) { \
if (str) \
str += len; \
inlen -= len; \
if (inlen < 0) \
inlen = 0; \
} \
#define strprint(str, inlen, ...) \
do { \
if (str) \
len = snprintf(str, inlen, ##__VA_ARGS__); \
else \
len = snprintf((char *){""}, 0, ##__VA_ARGS__); \
if (len < 0) { \
SYSERROR("failed to create string"); \
return -1; \
}; \
fulllen += len; \
if (inlen > 0) { \
if (str) \
str += len; \
inlen -= len; \
if (inlen < 0) \
inlen = 0; \
} \
} while (0);

extern int parse_idmaps(const char *idmap, char *type, unsigned long *nsid,
Expand Down

0 comments on commit ed40d79

Please sign in to comment.