On Thu, 2018-03-08 at 17:33 -0500, Simon Pichugin wrote: > Hi William! > Thank you for the email. It has clarified the things for me. :) > I still have one question though. > > Do I understand right that I need also to cast types with these types > from inttypes.h? > So use it not only in the defenitions. > - sprintf(buf, "%lu", (long unsigned int)maxsize); > + sprintf(buf, "%" PRIu64, (uint64_t)maxsize); There is PRIu32 too :) The pattern is: PRI<sign><size> IE PRIu64 - uint64_t PRId64 - int64_t PRIu32 - uint32_t PRId32 - int32_t Check what type maxsize is to be sure you use the correct PRI type. Hope that helps, > > Thanks, > Simon > > ----- Original Message ----- > > From: "William Brown" <william@xxxxxxxxxxxxxxxx> > > To: "389-devel" <389-devel@xxxxxxxxxxxxxxxxxxxxxxx> > > Sent: Thursday, March 8, 2018 12:42:03 AM > > Subject: Use of int types in the code base, > > > > Hi there, > > > > http://www.port389.org/docs/389ds/development/coding-style.html#typ > > es > > > > In a few reviews I still see this sometimes. > > > > It's pretty important that we keep moving our quality standard > > higher, > > and having known type sizes is important to this. Types like int > > and > > long are unknown sizes until you compile it depending on platform. > > > > As a result, it's really important we use the intX_t and uintX_t > > types > > so we have guarantees of our values. I would encourage the use of > > int64_t and uint64_t, because while they are "larger", it's > > significantly faster for a modern 64bit system to process these > > values > > than their 32bit counterparts. > > > > Another note is that arrays index by size_t, not 'int', so we > > should > > always keep this in mind. > > > > Finally, because we are using c99 now, this means we should avoid: > > > > size_t i = 0; > > > > for (i = 0; i < cond; i++) { > > ... > > } > > > > When we really should scope our values. Scoping is good because it > > limits possibility of data corruption to flow and other mistakes > > such > > as re-use of values. This means: > > > > for (size_t i = 0; i < cond; i++) { > > ... > > } > > > > Thanks! > > > > -- > > Thanks, > > > > William Brown > > -- Thanks, William Brown _______________________________________________ 389-devel mailing list -- 389-devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to 389-devel-leave@xxxxxxxxxxxxxxxxxxxxxxx