r3064: - use UINT8_MAX and UINT16_MAX instead of hex values for idr_get_new() limits
authorAndrew Tridgell <tridge@samba.org>
Tue, 19 Oct 2004 12:06:01 +0000 (12:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:01:55 +0000 (13:01 -0500)
 - change idr_get_new() to use > instead of >= in the limit check
(This used to be commit 834b09929bcb8aabdd151b7c2306001497cabdb4)

source4/include/includes.h
source4/lib/idtree.c
source4/ntvfs/posix/pvfs_open.c
source4/ntvfs/posix/pvfs_search.c
source4/smb_server/conn.c

index 85e4299efdf74c9e84570e2702b9aa1b214a7e97..0290f652ab5b4e1284be49dbe2248cb83f443098 100644 (file)
@@ -466,6 +466,14 @@ typedef int socklen_t;
 #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.
  */
index 80f7df97a0fa4783a3fa58b7db3a86f86a4c6b1a..1243c4f3b915bc68ab99a8a8c2a70980d53e3a94 100644 (file)
@@ -322,7 +322,7 @@ void *idr_init(TALLOC_CTX *mem_ctx)
 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;
        }
@@ -336,7 +336,7 @@ int idr_get_new(void *idp, void *ptr, int limit)
 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;
        }
index c2555583696f76ad05aa064e8527a8c400b5f450..fb81c86bcc38fdcb7de0b8d170251f3c07e4ee85 100644 (file)
@@ -157,7 +157,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
                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;
index 7b0da321d38e4de022bf6736d9f5f4928781869c..1464609e989cbcbc62fddf334a72500dc7b8fb13 100644 (file)
@@ -287,7 +287,7 @@ static NTSTATUS pvfs_search_first_old(struct ntvfs_module_context *ntvfs,
 
        /* 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;
        }
@@ -415,7 +415,7 @@ NTSTATUS pvfs_search_first(struct ntvfs_module_context *ntvfs,
                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;
        }
index 3cff83055dc7d1e05d557f60704c13d1c02fd80d..cdfd3a0bcd60b557f421e849293d70ed476f9a99 100644 (file)
@@ -59,7 +59,7 @@ struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
        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;