r25482: Slightly simplify logic
authorVolker Lendecke <vlendec@samba.org>
Wed, 3 Oct 2007 13:13:02 +0000 (13:13 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:31:07 +0000 (12:31 -0500)
Instead of one big if-branch for if (process_exists(..)) return if
(!process_exists(..))

source/rpc_server/srv_srvsvc_nt.c

index d89fe65274a745c79e7a6bb5f060c16ea1255a72..cc0968a5448783dee3461013cd5a27b489e044dc 100644 (file)
@@ -129,64 +129,64 @@ static void enum_file_fn( const struct share_mode_entry *e,
 {
        struct file_enum_count *fenum =
                (struct file_enum_count *)private_data;
+
+       struct srvsvc_NetFileInfo3 *f;
+       int i = fenum->count;
+       files_struct fsp;
+       struct byte_range_lock *brl;
+       int num_locks = 0;
+       pstring fullpath;
+       uint32 permissions;
  
        /* If the pid was not found delete the entry from connections.tdb */
 
-       if ( process_exists(e->pid) ) {
-               struct srvsvc_NetFileInfo3 *f;
-               int i = fenum->count;
-               files_struct fsp;
-               struct byte_range_lock *brl;
-               int num_locks = 0;
-               pstring fullpath;
-               uint32 permissions;
+       if (!process_exists(e->pid)) {
+               return;
+       }
                
-               f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 );                   
-               if ( !f ) {
-                       DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
-                       return;
-               }
-               fenum->info = f;
+       f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info,
+                                 struct srvsvc_NetFileInfo3, i+1 );
+       if ( !f ) {
+               DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1));
+               return;
+       }
+       fenum->info = f;
 
-               /* need to count the number of locks on a file */
+       /* need to count the number of locks on a file */
                
-               ZERO_STRUCT( fsp );             
-               fsp.file_id = e->id;
+       ZERO_STRUCT( fsp );             
+       fsp.file_id = e->id;
                
-               if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) {
-                       num_locks = brl->num_locks;
-                       TALLOC_FREE( brl );
-               }
+       if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) {
+               num_locks = brl->num_locks;
+               TALLOC_FREE( brl );
+       }
                
-               if ( strcmp( fname, "." ) == 0 ) {
-                       pstr_sprintf( fullpath, "C:%s", sharepath );
-               } else {
-                       pstr_sprintf( fullpath, "C:%s/%s", sharepath, fname );
-               }
-               string_replace( fullpath, '/', '\\' );
+       if ( strcmp( fname, "." ) == 0 ) {
+               pstr_sprintf( fullpath, "C:%s", sharepath );
+       } else {
+               pstr_sprintf( fullpath, "C:%s/%s", sharepath, fname );
+       }
+       string_replace( fullpath, '/', '\\' );
                
-               /* mask out create (what ever that is) */
-               permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA);
-
-               fenum->info[i].fid = e->share_file_id;
-               fenum->info[i].permissions = permissions;
-               fenum->info[i].num_locks = num_locks;
-               if (!(fenum->info[i].user = talloc_strdup(
-                             fenum->ctx, uidtoname(e->uid)))) {
-                       /* There's not much we can do here. */
-                       fenum->info[i].user = "";
-               }
-               if (!(fenum->info[i].path = talloc_strdup(
-                             fenum->ctx, fullpath))) {
-                       /* There's not much we can do here. */
-                       fenum->info[i].path = "";
-               }
-                       
-               fenum->count++;
+       /* mask out create (what ever that is) */
+       permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA);
+
+       fenum->info[i].fid = e->share_file_id;
+       fenum->info[i].permissions = permissions;
+       fenum->info[i].num_locks = num_locks;
+       if (!(fenum->info[i].user = talloc_strdup(
+                     fenum->ctx, uidtoname(e->uid)))) {
+               /* There's not much we can do here. */
+               fenum->info[i].user = "";
+       }
+       if (!(fenum->info[i].path = talloc_strdup(
+                     fenum->ctx, fullpath))) {
+               /* There's not much we can do here. */
+               fenum->info[i].path = "";
        }
-
-       return;
-
+                       
+       fenum->count++;
 }
 
 /*******************************************************************