r19154: Trivial logic simplification: Get rid of two indentation levels. Survives the
authorVolker Lendecke <vlendec@samba.org>
Fri, 6 Oct 2006 19:07:23 +0000 (19:07 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:15:17 +0000 (12:15 -0500)
consistency checks just checked into Samba4.

Volker
(This used to be commit c48bb4b37b32fac9d01d243290532641d3701ec7)

source3/rpc_server/srv_spoolss_nt.c

index 8d9ba7cb907496a3cf3047e4ff8e1159120c7b99..32cd5766af79763083194186f757537c613c9162 100644 (file)
@@ -4346,30 +4346,41 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32
        int i;
        int n_services=lp_numservices();
        PRINTER_INFO_1 *printers=NULL;
-       PRINTER_INFO_1 current_prt;
        WERROR result = WERR_OK;
        
        DEBUG(4,("enum_all_printers_info_1\n"));        
 
        for (snum=0; snum<n_services; snum++) {
-               if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
-                       struct share_params params;
-                       params.service = snum;
+               PRINTER_INFO_1 current_prt;
+               struct share_params params;
+               params.service = snum;
 
-                       DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+               if (!lp_browseable(snum) || !lp_snum_ok(snum) ||
+                   !lp_print_ok(snum) ) {
+                       continue;
+               }
 
-                       if (construct_printer_info_1(NULL, flags, &current_prt, &params)) {
-                               if((printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1, *returned +1)) == NULL) {
-                                       DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
-                                       *returned=0;
-                                       return WERR_NOMEM;
-                               }
-                               DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned));             
+               DEBUG(4,("Found a printer in smb.conf: %s[%x]\n",
+                        lp_servicename(snum), snum));
 
-                               memcpy(&printers[*returned], &current_prt, sizeof(PRINTER_INFO_1));
-                               (*returned)++;
-                       }
+               if (!construct_printer_info_1(NULL, flags, &current_prt,
+                                             &params)) {
+                       continue;
                }
+
+               if((printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1,
+                                              *returned +1)) == NULL) {
+                       DEBUG(2,("enum_all_printers_info_1: failed to enlarge "
+                                "printers buffer!\n"));
+                       *returned=0;
+                       return WERR_NOMEM;
+               }
+               DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n",
+                        *returned));
+
+               memcpy(&printers[*returned], &current_prt,
+                      sizeof(PRINTER_INFO_1));
+               (*returned)++;
        }
                
        /* check the required size. */  
@@ -4535,31 +4546,39 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3
        int i;
        int n_services=lp_numservices();
        PRINTER_INFO_2 *printers=NULL;
-       PRINTER_INFO_2 current_prt;
        WERROR result = WERR_OK;
 
        *returned = 0;
 
        for (snum=0; snum<n_services; snum++) {
-               if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
-                       struct share_params params;
-                       params.service = snum;
-                       DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
-
-                       if (construct_printer_info_2(NULL, &current_prt, &params)) {
-                               if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, *returned +1)) ) {
-                                       DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
-                                       *returned = 0;
-                                       return WERR_NOMEM;
-                               }
+               PRINTER_INFO_2 current_prt;
+               struct share_params params;
+               params.service = snum;
+               if (!lp_browseable(snum) || !lp_snum_ok(snum) ||
+                   !lp_print_ok(snum) ) {
+                       continue;
+               }
+               DEBUG(4,("Found a printer in smb.conf: %s[%x]\n",
+                        lp_servicename(snum), snum));
 
-                               DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned + 1));         
+               if (!construct_printer_info_2(NULL, &current_prt,
+                                             &params)) {
+                       continue;
+               }
+               if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2,
+                                                 *returned +1)) ) {
+                       DEBUG(2,("enum_all_printers_info_2: failed to enlarge "
+                                "printers buffer!\n"));
+                       *returned = 0;
+                       return WERR_NOMEM;
+               }
 
-                               memcpy(&printers[*returned], &current_prt, sizeof(PRINTER_INFO_2));
+               DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n",
+                        *returned + 1));
 
-                               (*returned)++;
-                       }
-               }
+               memcpy(&printers[*returned], &current_prt,
+                      sizeof(PRINTER_INFO_2));
+               (*returned)++;
        }
        
        /* check the required size. */