Changeset 688:94da28639c7f


Ignore:
Timestamp:
05/21/08 16:16:49 (2 years ago)
Author:
Mateusz Loskot <mateusz@…>
Branch:
default
Convert:
svn:1766ff46-f334-0410-ab20-d63176f87757/trunk@756
Message:

Get rid of warning C4127 when building with Visual C++. Removed unreachable code - no need to return from every catch clause of try-catch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/las_c_api.cpp

    r662 r688  
    6464#include <exception> 
    6565#include <vector> 
    66  
     66#include <sstream> // std::stringstream 
     67#include <fstream> 
    6768#include <iostream> 
    68 #include <fstream> 
    6969using namespace liblas; 
    7070 
     
    9595static std::stack<LASError > errors; 
    9696 
     97#ifdef _MSC_VER 
     98# pragma warning(disable: 4127) // warning C4127: conditional expression is constant 
     99#endif 
     100 
    97101#define VALIDATE_POINTER0(ptr, func) \ 
    98    do { if( NULL == ptr ) \ 
    99       { \ 
     102   do { if( NULL == ptr ) { \ 
    100103        LASErrorEnum const ret = LE_Failure; \ 
    101104        std::ostringstream msg; \ 
    102105        msg << "Pointer \'" << #ptr << "\' is NULL in \'" << (func) <<"\'."; \ 
    103106        std::string message(msg.str()); \ 
    104         LASError_PushError( ret, \ 
    105            message.c_str(), (func)); \ 
    106          return; }} while(0) 
     107        LASError_PushError( ret, message.c_str(), (func)); \ 
     108        return; \ 
     109   }} while(0) 
    107110 
    108111#define VALIDATE_POINTER1(ptr, func, rc) \ 
    109    do { if( NULL == ptr ) \ 
    110       { \ 
     112   do { if( NULL == ptr ) { \ 
    111113        LASErrorEnum const ret = LE_Failure; \ 
    112114        std::ostringstream msg; \ 
    113115        msg << "Pointer \'" << #ptr << "\' is NULL in \'" << (func) <<"\'."; \ 
    114116        std::string message(msg.str()); \ 
    115         LASError_PushError( ret, \ 
    116            message.c_str(), (func)); \ 
    117         return (rc); }} while(0) 
     117        LASError_PushError( ret, message.c_str(), (func)); \ 
     118        return (rc); \ 
     119   }} while(0) 
    118120 
    119121LAS_DLL void LASError_Reset(void) { 
     
    269271    } catch (invalid_point_data const& e /*e */) { 
    270272        LASError_PushError(LE_Failure, e.what(), "LASReader_GetNextPoint Invalid Point"); 
    271         return NULL; 
    272273    } catch (std::exception const& e) 
    273274    { 
    274275        LASError_PushError(LE_Failure, e.what(), "LASReader_GetNextPoint"); 
    275         return NULL; 
    276276    } 
    277277  
    278278    return NULL; 
    279  
    280279} 
    281280 
     
    293292    } catch (invalid_point_data const& e /*e */) { 
    294293        LASError_PushError(LE_Failure, e.what(), "LASReader_GetPointAt Invalid Point"); 
    295         return NULL; 
    296294    } catch (std::exception const& e) 
    297295    { 
    298296        LASError_PushError(LE_Failure, e.what(), "LASReader_GetPointAt"); 
    299         return NULL; 
    300297    } 
    301298  
     
    860857LAS_DLL liblas::uint8_t LASHeader_GetDataFormatId(const LASHeaderH hHeader) { 
    861858    VALIDATE_POINTER1(hHeader, "LASHeader_GetDataFormatId", 0); 
    862  
    863     unsigned char value = ((LASHeader*) hHeader)->GetDataFormatId(); 
    864     return value; 
     859     
     860    LASHeader::PointFormat id = ((LASHeader*) hHeader)->GetDataFormatId(); 
     861    return static_cast<liblas::uint8_t>(id); 
    865862} 
    866863 
     
    15071504LAS_C_END 
    15081505 
     1506#ifdef _MSC_VER 
     1507# pragma warning(default: 4127) // enable warning C4127: conditional expression is constant 
     1508#endif 
Note: See TracChangeset for help on using the changeset viewer.