Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Negative file descriptor  at tracer.c:209

Categories: POSIX.IO.NEGFD
Warning ID: 2873.2939
Procedure: work
Trace: View
Modified: Wed Sep 2 12:51:39 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /u1/paul/SATE/2010/c/pvm/pvm3/tracer/tracer.c
   Enter work
 107 work() 
 108 {
 109         struct timeval more_events;
 110  
 111         struct timeval *timeout;
 112  
 113         char cmd[1024];
 114  
 115         char *prompt;
 116  
 117 #ifdef FDSETNOTSTRUCT 
   ...
 133  
 134 #ifdef WIN32 
 135 #define read _read 
 136         HANDLE hStdin;
 137         struct timeval zerotimeout = { 0, 0 };
 138         hStdin = GetStdHandle(STD_INPUT_HANDLE); 
 139 #endif 
 140  
 141         /* Initialize File Descriptors */ 
 142  
 143         FD_ZERO( &rfds );
 144  
 145         /* Get stdin input */ 
 146 #ifndef WIN32 
true147         in = fileno( stdin );
 148  
 149         FD_SET( in, &rfds );   /* Negative Shift Amount (ID: 2875.2941) */
 150  
 151         nfds = 1;
 152 #else 
 153         i=0; 
 154 #endif 
 155         /* Get PVM Sockets */ 
 156  
 157         if ( pvm_getfds( &np ) > 0 )
 158         {
 159                 FD_SET( np[0], &rfds );
 160  
 161                 nfds = np[0] + 1;
 162         }
 163  
 164         /* Initialize Select Timeout - For Events Still Pending */ 
 165  
 166         more_events.tv_sec = 0;
 167         more_events.tv_usec = 0;
 168  
 169         /* Print Initial Prompt */ 
 170  
 171         prompt = "tracer> ";
 172  
 173         printf( prompt );
 174         fflush( stdout );
 175  
 176         /* Process Events Messages and User Input */ 
 177  
 178         while ( 1 )
 179         {
 180                 /* Check for Event Messages */ 
 181  
 182                 more = recv_events();
 183  
 184                 if ( more )
 185                         timeout = &more_events;
 186                  
 187                 else 
 188 #ifndef WIN32 
 189                         timeout = (struct timeval *) NULL;
 190 #else 
 191                         timeout = &zerotimeout; 
 192 #endif 
 193  
 194                 /* Wait for Input */ 
 195  
 196                 fds = rfds;
 197  
 198                 if ( (n = SELECT( nfds, &fds, NULL, NULL, timeout )) == -1 )
 199                         perror( "select" );
 200  
 201 #ifdef WIN32 
 202                 else if (WAIT_TIMEOUT == WaitForSingleObject(hStdin,2000) )
 203                         continue; /* no input */ 
 204 #else 
 205                 else if ( n > 0 && FD_ISSET( in, &fds ) )   /* Negative Shift Amount (ID: 2874.2940) */
 206 #endif 
 207                 {
 208 #ifndef WIN32 
in <= -1209                         if ( (n = read(in, cmd, sizeof( cmd ) - 1 )) < 1 )     /* Negative file descriptor */
 210 #else 
 211         /* even if I set in=0 -> read(in, ...) fails. must be explicityly 0 !  
 212            am I missing something ?
 213         */ 
 214                         if ( (n = read(0, cmd, sizeof( cmd ) - 1 )) < 1 ) 
 215  
 216 #endif 
 217                         {
 218                                 printf( "Quit\n" );
 219  
 220                                 quit_proc();
 221                         }
 222  
 223                         else 
 224                         {
 225                                 cmd[ n ] = '\0';
 226  
 227                                 handle_cmd( cmd );
 228  
 229                                 printf( prompt );
 230                                 fflush( stdout );
Preconditions
ID->output_ctx != -1
ID->output_tag != -1
ID->event_ctx != -1
ID->event_tag != -1
TRC_HOST_DEL_NOTIFY_CODE != -1
pvmautoerr != 2
pvmautoerr != 3
pvmmytid = -1
stdout >= 0
Postconditions
*stdin' is allocated by fopen
bytes_before(stdin)' = 0
__arr' = &rfds.__fds_bits[0]
__i' = 16
in' = -1
more' = 0
more_events.tv_sec' = 0
more_events.tv_usec' = 0
n' = 1
nfds' = 1
prompt' = &#string0[0]
rfds.__fds_bits[15]' = 0
timeout' = 0




Change Warning 2873.2939 : Negative file descriptor

Priority:
State:
Finding:
Owner:
Note: