This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] breakpoint.c ARI fixes


This patch tries to removes to types
of ARI warnings for breakpoint.c source.

  Operators at end of line (against coding standards)
and assignments inside if statements.

  The reason why I didn't check them in as obvious
is only that for some of the if assignment rules,
the assignment appear as a second test, meaning
that it is not always executed in old code, while it is 
in new code in print_one_breakpoint_location.
  But as the assignment doesn't call any function,
I still think that the change is OK.
  The assignment is dereferencing a pointer, but
this pointer needs to be valid anyhow, regardless of the
first test, because dereferencing already occurs earlier in 
this function.

   Is this OK?

I would like to know if the minimal ChangeLog
below is enough or if I should use the long version
listing all modified functions.

Pierre Muller

PS: Test checked on CompileFarm on a linux-amd64 machine,
no change in testsuite results.
 
  
ChangeLog entry, short version:

2009-06-09  Pierre Muller  <muller@ics.u-strasbg.fr>

	* breakpoint.c: ARI fixes.

ChangeLog entry, long version:

2009-06-09  Pierre Muller  <muller@ics.u-strasbg.fr>

	* breakpoint.c : ARI fixes.
	(create_overlay_event_breakpoint): Avoid assignment inside if
statement.
	(print_one_breakpoint_location): Likewise.
	(create_longjmp_breakpoint): Likewise.
	(tracepoint_save_command): Likewise
	(bpstat_find_step_resume_breakpoint): No operator at end of line.
	(bpstat_stop_status): Likewise.
	(describe_other_breakpoints): Likewise.
	(hw_watchpoint_used_count): Likewise.
	(expand_line_sal_maybe): Likewise.
	(break_command_really): Likewise.
	(catch_exception_command_1): Likewise.
	(delete_command): Likewise.
	(do_enable_breakpoint): Likewise.
	(delete_trace_command): Likewise.

Index: src/gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.403
diff -u -p -r1.403 breakpoint.c
--- src/gdb/breakpoint.c	8 Jun 2009 16:05:14 -0000	1.403
+++ src/gdb/breakpoint.c	8 Jun 2009 22:48:55 -0000
@@ -1478,7 +1478,8 @@ create_overlay_event_breakpoint (char *f
   struct breakpoint *b;
   struct minimal_symbol *m;
 
-  if ((m = lookup_minimal_symbol_text (func_name, objfile)) == NULL)
+  m = lookup_minimal_symbol_text (func_name, objfile);
+  if (m == NULL)
     return;
 
   b = create_internal_breakpoint (SYMBOL_VALUE_ADDRESS (m),
@@ -2128,10 +2129,10 @@ bpstat_find_step_resume_breakpoint (bpst
 
   for (; bsp != NULL; bsp = bsp->next)
     {
-      if ((bsp->breakpoint_at != NULL) &&
-	  (bsp->breakpoint_at->owner->type == bp_step_resume) &&
-	  (bsp->breakpoint_at->owner->thread == current_thread || 
-	   bsp->breakpoint_at->owner->thread == -1))
+      if ((bsp->breakpoint_at != NULL)
+	  && (bsp->breakpoint_at->owner->type == bp_step_resume)
+	  && (bsp->breakpoint_at->owner->thread == current_thread
+	      || bsp->breakpoint_at->owner->thread == -1))
 	return bsp->breakpoint_at->owner;
     }
 
@@ -3132,9 +3133,9 @@ bpstat_stop_status (CORE_ADDR bp_addr, p
 	if (b->silent)
 	  bs->print = 0;
 	bs->commands = b->commands;
-	if (bs->commands &&
-	    (strcmp ("silent", bs->commands->line) == 0
-	     || (xdb_commands && strcmp ("Q", bs->commands->line) == 0)))
+	if (bs->commands
+	    && (strcmp ("silent", bs->commands->line) == 0
+		|| (xdb_commands && strcmp ("Q", bs->commands->line) == 0)))
 	  {
 	    bs->commands = bs->commands->next;
 	    bs->print = 0;
@@ -3747,8 +3748,9 @@ print_one_breakpoint_location (struct br
       ui_out_field_int (uiout, "ignore", b->ignore_count);
       ui_out_text (uiout, " hits\n");
     }
-  
-  if (!part_of_multiple && (l = b->commands))
+
+  l = b->commands;
+  if (!part_of_multiple && l)
     {
       struct cleanup *script_chain;
 
@@ -4043,8 +4045,8 @@ describe_other_breakpoints (CORE_ADDR pc
 	    else if (b->thread != -1)
 	      printf_filtered (" (thread %d)", b->thread);
 	    printf_filtered ("%s%s ",
-			     ((b->enable_state == bp_disabled || 
-			       b->enable_state == bp_call_disabled) 
+			     ((b->enable_state == bp_disabled
+			       || b->enable_state == bp_call_disabled) 
 			      ? " (disabled)"
 			      : b->enable_state == bp_permanent 
 			      ? " (permanent)"
@@ -4425,7 +4427,8 @@ create_longjmp_breakpoint (char *func_na
 {
   struct minimal_symbol *m;
 
-  if ((m = lookup_minimal_symbol_text (func_name, NULL)) == NULL)
+  m = lookup_minimal_symbol_text (func_name, NULL);
+  if (m == NULL)
     return;
   set_momentary_breakpoint_at_pc (SYMBOL_VALUE_ADDRESS (m), bp_longjmp);
   update_global_location_list (1);
@@ -4931,9 +4934,9 @@ hw_watchpoint_used_count (enum bptype ty
       {
 	if (b->type == type)
 	  i++;
-	else if ((b->type == bp_hardware_watchpoint ||
-		  b->type == bp_read_watchpoint ||
-		  b->type == bp_access_watchpoint))
+	else if ((b->type == bp_hardware_watchpoint
+		  || b->type == bp_read_watchpoint
+		  || b->type == bp_access_watchpoint))
 	  *other_type_used = 1;
       }
   }
@@ -5403,8 +5406,8 @@ expand_line_sal_maybe (struct symtab_and
 	  if (find_pc_partial_function (pc, &this_function, 
 					&func_addr, &func_end))
 	    {
-	      if (this_function && 
-		  strcmp (this_function, original_function) != 0)
+	      if (this_function
+		  && strcmp (this_function, original_function) != 0)
 		{
 		  remove_sal (&expanded, i);
 		  --i;
@@ -5725,8 +5728,8 @@ break_command_really (char *arg, char *c
 
           /* If pending breakpoint support is auto query and the user
 	     selects no, then simply return the error code.  */
-	  if (pending_break_support == AUTO_BOOLEAN_AUTO && 
-	      !nquery ("Make breakpoint pending on future shared library
load? "))
+	  if (pending_break_support == AUTO_BOOLEAN_AUTO
+	      && !nquery ("Make breakpoint pending on future shared library
load? "))
 	    return;
 
 	  /* At this point, either the user was queried about setting
@@ -6772,8 +6775,8 @@ catch_exception_command_1 (enum exceptio
   if ((*arg != '\0') && !isspace (*arg))
     error (_("Junk at end of arguments."));
 
-  if ((ex_event != EX_EVENT_THROW) &&
-      (ex_event != EX_EVENT_CATCH))
+  if ((ex_event != EX_EVENT_THROW)
+      && (ex_event != EX_EVENT_CATCH))
     error (_("Unsupported or unknown exception event; cannot catch it"));
 
   if (handle_gnu_v3_exceptions (tempflag, cond_string, ex_event, from_tty))
@@ -7396,11 +7399,11 @@ delete_command (char *arg, int from_tty)
          have to be deleted with an explicit breakpoint number argument.
*/
       ALL_BREAKPOINTS (b)
       {
-	if (b->type != bp_call_dummy &&
-	    b->type != bp_shlib_event &&
-	    b->type != bp_thread_event &&
-	    b->type != bp_overlay_event &&
-	    b->number >= 0)
+	if (b->type != bp_call_dummy
+	    && b->type != bp_shlib_event
+	    && b->type != bp_thread_event
+	    && b->type != bp_overlay_event
+	    && b->number >= 0)
 	  {
 	    breaks_to_delete = 1;
 	    break;
@@ -7413,11 +7416,11 @@ delete_command (char *arg, int from_tty)
 	{
 	  ALL_BREAKPOINTS_SAFE (b, temp)
 	  {
-	    if (b->type != bp_call_dummy &&
-		b->type != bp_shlib_event &&
-		b->type != bp_thread_event &&
-		b->type != bp_overlay_event &&
-		b->number >= 0)
+	    if (b->type != bp_call_dummy
+		&& b->type != bp_shlib_event
+		&& b->type != bp_thread_event
+		&& b->type != bp_overlay_event
+		&& b->number >= 0)
 	      delete_breakpoint (b);
 	  }
 	}
@@ -8028,10 +8031,10 @@ do_enable_breakpoint (struct breakpoint 
 	error (_("Hardware breakpoints used exceeds limit."));
     }
 
-  if (bpt->type == bp_watchpoint || 
-      bpt->type == bp_hardware_watchpoint ||
-      bpt->type == bp_read_watchpoint || 
-      bpt->type == bp_access_watchpoint)
+  if (bpt->type == bp_watchpoint
+      || bpt->type == bp_hardware_watchpoint
+      || bpt->type == bp_read_watchpoint
+      || bpt->type == bp_access_watchpoint)
     {
       struct gdb_exception e;
 
@@ -8366,8 +8369,8 @@ delete_trace_command (char *arg, int fro
 	{
 	  ALL_BREAKPOINTS_SAFE (b, temp)
 	  {
-	    if (b->type == bp_tracepoint &&
-		b->number >= 0)
+	    if (b->type == bp_tracepoint
+		&& b->number >= 0)
 	      delete_breakpoint (b);
 	  }
 	}
@@ -8514,7 +8517,8 @@ tracepoint_save_command (char *args, int
 
   pathname = tilde_expand (args);
   cleanup = make_cleanup (xfree, pathname);
-  if (!(fp = fopen (pathname, "w")))
+  fp = fopen (pathname, "w");
+  if (!fp)
     error (_("Unable to open file '%s' for saving tracepoints (%s)"),
 	   args, safe_strerror (errno));
   make_cleanup_fclose (fp);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]