X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=CodingStyle;h=6ac03167dfe0bf13194e493e33ead5ea2f3f56ce;hb=db19b72b9f6d0d40b743214241d9666116e3b448;hp=2f24ee396f057ded30413ad71e80e46797d10be9;hpb=bd3ad2c3508aaf7283f3ee041ecd3e5108471b21;p=sliver-openvswitch.git diff --git a/CodingStyle b/CodingStyle index 2f24ee396..6ac03167d 100644 --- a/CodingStyle +++ b/CodingStyle @@ -224,7 +224,7 @@ statement, that is, write "return 0;" and not "return(0);" break; default: - NOT_REACHED(); + OVS_NOT_REACHED(); } "switch" statements with very short, uniform cases may use an @@ -394,7 +394,21 @@ from . integer types. Use the PRId, PRIu, and PRIx macros from for formatting them with printf() and related functions. - Use %zu to format size_t with printf(). + For compatibility with antique printf() implementations: + + - Instead of "%zu", use "%"PRIuSIZE. + + - Instead of "%td", use "%"PRIdPTR. + + - Instead of "%ju", use "%"PRIuMAX. + +Other variants exist for different radixes. For example, use +"%"PRIxSIZE instead of "%zx" or "%x" instead of "%hhx". + + Also, instead of "%hhd", use "%d". Be cautious substituting "%u", +"%x", and "%o" for the corresponding versions with "hh": cast the +argument to unsigned char if necessary, because printf("%hhu", -1) +prints 255 but printf("%u", -1) prints 4294967295. Use bit-fields sparingly. Do not use bit-fields for layout of network protocol fields or in other circumstances where the exact