2525#include " ibase.h"
2626#include " ../yvalve/gds_proto.h"
2727
28- static const USHORT SEGMENT_LIMIT = 65535 ;
29- // static SLONG fb_vax_integer(const UCHAR* ptr, int length);
28+ static constexpr USHORT SEGMENT_LIMIT = 65535 ;
3029
3130
3231bool UserBlob::open (FB_API_HANDLE& db, FB_API_HANDLE& trans, ISC_QUAD& blobid)
@@ -117,7 +116,7 @@ bool UserBlob::getSegment(FB_SIZE_T len, void* buffer, FB_SIZE_T& real_len)
117116#endif
118117
119118 USHORT olen = 0 ;
120- USHORT ilen = len > SEGMENT_LIMIT ? SEGMENT_LIMIT : static_cast <USHORT>(len);
119+ const USHORT ilen = len > SEGMENT_LIMIT ? SEGMENT_LIMIT : static_cast <USHORT>(len);
121120 char * buf2 = static_cast <char *>(buffer);
122121 if (!isc_get_segment (m_status, &m_blob, &olen, ilen, buf2) || m_status[1 ] == isc_segment)
123122 {
@@ -142,7 +141,7 @@ bool UserBlob::getData(FB_SIZE_T len, void* buffer, FB_SIZE_T& real_len,
142141 while (len)
143142 {
144143 USHORT olen = 0 ;
145- USHORT ilen = len > SEGMENT_LIMIT ? SEGMENT_LIMIT : static_cast <USHORT>(len);
144+ const USHORT ilen = len > SEGMENT_LIMIT ? SEGMENT_LIMIT : static_cast <USHORT>(len);
146145 if (!isc_get_segment (m_status, &m_blob, &olen, ilen, buf2) || m_status[1 ] == isc_segment)
147146 {
148147 len -= olen;
@@ -172,7 +171,7 @@ bool UserBlob::putSegment(FB_SIZE_T len, const void* buffer)
172171 return false ;
173172#endif
174173
175- USHORT ilen = len > SEGMENT_LIMIT ? SEGMENT_LIMIT : static_cast <USHORT>(len);
174+ const USHORT ilen = len > SEGMENT_LIMIT ? SEGMENT_LIMIT : static_cast <USHORT>(len);
176175 const char * buf2 = static_cast <const char *>(buffer);
177176 return !isc_put_segment (m_status, &m_blob, ilen, buf2);
178177}
@@ -227,8 +226,8 @@ bool UserBlob::getInfo(FB_SIZE_T items_size, const UCHAR* items,
227226 return false ;
228227
229228 // We have to cater for the API limitations.
230- SSHORT in_len = items_size > MAX_SSHORT ? MAX_SSHORT : static_cast <SSHORT>(items_size);
231- SSHORT out_len = info_size > MAX_SSHORT ? MAX_SSHORT : static_cast <SSHORT>(info_size);
229+ const SSHORT in_len = static_cast <SSHORT>(MIN ( items_size, MAX_SSHORT) );
230+ const SSHORT out_len = static_cast <SSHORT>(MIN ( info_size, MAX_SSHORT) );
232231 // That the API declares the second param as non const is a bug.
233232 FB_API_HANDLE blob = m_blob;
234233 return !isc_blob_info (m_status, &blob,
0 commit comments