#define uint64 uint64_t
#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX 255
+#endif
+
+#ifndef UINT16_MAX
+#define UINT16_MAX 65535
+#endif
+
/*
* Types for devices, inodes and offsets.
*/
int idr_get_new(void *idp, void *ptr, int limit)
{
int ret = idr_get_new_above_int((struct idr *)idp, ptr, 0);
- if (ret >= limit) {
+ if (ret > limit) {
idr_remove(idp, ret);
return -1;
}
int idr_get_new_above(void *idp, void *ptr, int starting_id, int limit)
{
int ret = idr_get_new_above_int((struct idr *)idp, ptr, starting_id);
- if (ret >= limit) {
+ if (ret > limit) {
idr_remove(idp, ret);
return -1;
}
return NT_STATUS_NO_MEMORY;
}
- fnum = idr_get_new(pvfs->idtree_fnum, f, 0x10000);
+ fnum = idr_get_new(pvfs->idtree_fnum, f, UINT16_MAX);
if (fnum == -1) {
talloc_free(f);
return NT_STATUS_TOO_MANY_OPENED_FILES;
/* we need to give a handle back to the client so it
can continue a search */
- id = idr_get_new(pvfs->idtree_search, search, 0x100);
+ id = idr_get_new(pvfs->idtree_search, search, UINT8_MAX);
if (id == -1) {
return NT_STATUS_INSUFFICIENT_RESOURCES;
}
return status;
}
- id = idr_get_new(pvfs->idtree_search, search, 0x10000);
+ id = idr_get_new(pvfs->idtree_search, search, UINT16_MAX);
if (id == -1) {
return NT_STATUS_INSUFFICIENT_RESOURCES;
}
tcon = talloc_zero_p(smb_conn, struct smbsrv_tcon);
if (!tcon) return NULL;
- i = idr_get_new(smb_conn->tree.idtree_tid, tcon, UINT16_MAX + 1);
+ i = idr_get_new(smb_conn->tree.idtree_tid, tcon, UINT16_MAX);
if (i == -1) {
DEBUG(1,("ERROR! Out of connection structures\n"));
return NULL;