unwind: use sizeof() instead of hardcoded sizes
The statically allocated strings have a fixed size which can be computed using the sizeof operator rather than duplicating the allocation size which can drift. NFC. llvm-svn: 229126
This commit is contained in:
		
							parent
							
								
									cc39d3f4bd
								
							
						
					
					
						commit
						ebfe815f5c
					
				| 
						 | 
					@ -473,8 +473,9 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
 | 
				
			||||||
      char functionBuf[512];
 | 
					      char functionBuf[512];
 | 
				
			||||||
      const char *functionName = functionBuf;
 | 
					      const char *functionName = functionBuf;
 | 
				
			||||||
      unw_word_t offset;
 | 
					      unw_word_t offset;
 | 
				
			||||||
      if ((unw_get_proc_name(&cursor1, functionBuf, 512, &offset) !=
 | 
					      if ((unw_get_proc_name(&cursor1, functionBuf, sizeof(functionBuf),
 | 
				
			||||||
           UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
					                             &offset) != UNW_ESUCCESS) ||
 | 
				
			||||||
 | 
					          (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
				
			||||||
        functionName = ".anonymous.";
 | 
					        functionName = ".anonymous.";
 | 
				
			||||||
      unw_word_t pc;
 | 
					      unw_word_t pc;
 | 
				
			||||||
      unw_get_reg(&cursor1, UNW_REG_IP, &pc);
 | 
					      unw_get_reg(&cursor1, UNW_REG_IP, &pc);
 | 
				
			||||||
| 
						 | 
					@ -604,8 +605,9 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
 | 
				
			||||||
      char functionBuf[512];
 | 
					      char functionBuf[512];
 | 
				
			||||||
      const char *functionName = functionBuf;
 | 
					      const char *functionName = functionBuf;
 | 
				
			||||||
      unw_word_t offset;
 | 
					      unw_word_t offset;
 | 
				
			||||||
      if ((unw_get_proc_name(&cursor2, functionBuf, 512, &offset) !=
 | 
					      if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
 | 
				
			||||||
           UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
					                             &offset) != UNW_ESUCCESS) ||
 | 
				
			||||||
 | 
					          (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
				
			||||||
        functionName = ".anonymous.";
 | 
					        functionName = ".anonymous.";
 | 
				
			||||||
      _LIBUNWIND_TRACE_UNWINDING(
 | 
					      _LIBUNWIND_TRACE_UNWINDING(
 | 
				
			||||||
          "unwind_phase2(ex_ojb=%p): start_ip=0x%llX, func=%s, sp=0x%llX, "
 | 
					          "unwind_phase2(ex_ojb=%p): start_ip=0x%llX, func=%s, sp=0x%llX, "
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,8 +63,9 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
 | 
				
			||||||
      char functionBuf[512];
 | 
					      char functionBuf[512];
 | 
				
			||||||
      const char *functionName = functionBuf;
 | 
					      const char *functionName = functionBuf;
 | 
				
			||||||
      unw_word_t offset;
 | 
					      unw_word_t offset;
 | 
				
			||||||
      if ((unw_get_proc_name(&cursor1, functionBuf, 512, &offset) !=
 | 
					      if ((unw_get_proc_name(&cursor1, functionBuf, sizeof(functionBuf),
 | 
				
			||||||
           UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
					                             &offset) != UNW_ESUCCESS) ||
 | 
				
			||||||
 | 
					          (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
				
			||||||
        functionName = ".anonymous.";
 | 
					        functionName = ".anonymous.";
 | 
				
			||||||
      unw_word_t pc;
 | 
					      unw_word_t pc;
 | 
				
			||||||
      unw_get_reg(&cursor1, UNW_REG_IP, &pc);
 | 
					      unw_get_reg(&cursor1, UNW_REG_IP, &pc);
 | 
				
			||||||
| 
						 | 
					@ -160,8 +161,9 @@ unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
 | 
				
			||||||
      char functionBuf[512];
 | 
					      char functionBuf[512];
 | 
				
			||||||
      const char *functionName = functionBuf;
 | 
					      const char *functionName = functionBuf;
 | 
				
			||||||
      unw_word_t offset;
 | 
					      unw_word_t offset;
 | 
				
			||||||
      if ((unw_get_proc_name(&cursor2, functionBuf, 512, &offset) !=
 | 
					      if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
 | 
				
			||||||
           UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
					                             &offset) != UNW_ESUCCESS) ||
 | 
				
			||||||
 | 
					          (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
				
			||||||
        functionName = ".anonymous.";
 | 
					        functionName = ".anonymous.";
 | 
				
			||||||
      _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIx64
 | 
					      _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIx64
 | 
				
			||||||
                                 ", func=%s, sp=0x%" PRIx64 ", lsda=0x%" PRIx64
 | 
					                                 ", func=%s, sp=0x%" PRIx64 ", lsda=0x%" PRIx64
 | 
				
			||||||
| 
						 | 
					@ -251,8 +253,9 @@ unwind_phase2_forced(unw_context_t *uc,
 | 
				
			||||||
      char functionBuf[512];
 | 
					      char functionBuf[512];
 | 
				
			||||||
      const char *functionName = functionBuf;
 | 
					      const char *functionName = functionBuf;
 | 
				
			||||||
      unw_word_t offset;
 | 
					      unw_word_t offset;
 | 
				
			||||||
      if ((unw_get_proc_name(&cursor2, functionBuf, 512, &offset) !=
 | 
					      if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
 | 
				
			||||||
           UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
					                             &offset) != UNW_ESUCCESS) ||
 | 
				
			||||||
 | 
					          (frameInfo.start_ip + offset > frameInfo.end_ip))
 | 
				
			||||||
        functionName = ".anonymous.";
 | 
					        functionName = ".anonymous.";
 | 
				
			||||||
      _LIBUNWIND_TRACE_UNWINDING(
 | 
					      _LIBUNWIND_TRACE_UNWINDING(
 | 
				
			||||||
          "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIx64
 | 
					          "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIx64
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue