int c = 0;
if (f & TBM_BO_SCANOUT)
- c = snprintf(&str[c], 255, "SCANOUT");
+ c += snprintf(&str[c], 255-c, "SCANOUT");
if (f & TBM_BO_NONCACHABLE) {
- if (c)
- c = snprintf(&str[c], 255, ", ");
- c = snprintf(&str[c], 255, "NONCACHABLE,");
+ if (c >= 0 && c < 255)
+ c += snprintf(&str[c], 255-c, ", ");
+
+ if (c >= 0 && c < 255)
+ c += snprintf(&str[c], 255-c, "NONCACHABLE,");
}
if (f & TBM_BO_WC) {
- if (c)
- c = snprintf(&str[c], 255, ", ");
- c = snprintf(&str[c], 255, "WC");
+ if (c >= 0 && c < 255)
+ c += snprintf(&str[c], 255-c, ", ");
+
+ if (c >= 0 && c < 255)
+ c += snprintf(&str[c], 255-c, "WC");
}
}