Çözüldü [-Waddress],[-Wnonnull-compare],[-Wformat-truncation=] Warning

Bu konu çözüme ulaştırılmıştır. Çözüm için konuya yazılan tüm yorumları okumayı unutmayın. Eğer konudaki yorumlar sorununuzu çözmediyse yeni bir konu açabilirsiniz.

MEKA

Discord: mekaprojects
Site yetkilisi
Süper Moderatör
Premium Üye
Grafiker
Geliştirici
Yardımsever Üye
Mesaj
2.788
Çözümler
287
Beğeni
2.033
Puan
1.850
Ticaret Puanı
2
Takıldığım bu warningler var bunların çözümleri var mı ? (Makefile ile gizlemek istemiyorum.)

Kod:
DragonSoul.cpp: In member function 'bool DSManager::DoRefineGrade(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:510:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  510 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStep(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:670:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  670 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStrength(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:831:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  831 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineGrade(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:510:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  510 |  if (NULL == aItemPoses)
      |  ^~
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStep(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:670:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  670 |  if (NULL == aItemPoses)
      |  ^~
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStrength(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:831:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  831 |  if (NULL == aItemPoses)
      |  ^~


Kod:
panama.cpp: In function 'size_t PanamaLoad()':
panama.cpp:26:56: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size 249 [-Wformat-truncation=]
   26 |   snprintf(szIVFileName, sizeof(szIVFileName), "panama/%s", szIVFileNameConfig);
      |                                                        ^~   ~~~~~~~~~~~~~~~~~~
panama.cpp:26:11: note: 'snprintf' output between 8 and 263 bytes into a destination of size 256
   26 |   snprintf(szIVFileName, sizeof(szIVFileName), "panama/%s", szIVFileNameConfig);
      |   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kod:
ProtoReader.cpp: In function 'int get_Item_SubType_Value(int, std::string)':
ProtoReader.cpp:314:29: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
  314 |  assert(_countof(arSubType) > type_value && "Subtype rule: Out of range!!");
ProtoReader.cpp:316:26: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
  316 |  if (_countof(arSubType) <= type_value)

Kod:
ClientManager.cpp: In member function 'void CClientManager::MainLoop()':
ClientManager.cpp:236:3: warning: deleting object of polymorphic class type 'CItemPriceListTableCache' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
  236 |   delete pCache;
      |   ^~~~~~~~~~~~~
ClientManager.cpp: In member function 'int CClientManager::Process()':
ClientManager.cpp:2985:64: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
 2985 |     if (!(thecore_heart->pulse % thecore_heart->passes_per_sec * 10))
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~

Kod:
In file included from ../../common/singleton.h:4,
                 from stdafx.h:15,
                 from ProtoReader.cpp:1:
ProtoReader.cpp: In function 'int get_Item_SubType_Value(int, std::string)':
ProtoReader.cpp:313:29: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
  313 |  assert(_countof(arSubType) > type_value && "Subtype rule: Out of range!!");
ProtoReader.cpp:315:26: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
  315 |  if (_countof(arSubType) <= type_value)

Kod:
Cache.cpp: In member function 'virtual void CItemCache::OnFlush()':
Cache.cpp:142:79: warning: '%s' directive output may be truncated writing up to 8191 bytes into a region of size between 8165 and 16356 [-Wformat-truncation=]
  142 |   snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues);
      |                                                                               ^~                                  ~~~~~~~~
Cache.cpp:142:11: note: 'snprintf' output 30 or more bytes (assuming 16412) into a destination of size 16384
  142 |   snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues);
      |   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Son düzenleme:
Çözüm
BUNLARI DENERMİSİN

panama.cpp
arat :
C++:
        char szIVFileName[256];

değiştir:
C++:
        char szIVFileName[263];

ProtoReader.cpp
ara :
C++:
int get_Item_SubType_Value(int type_value, string inputString)

değiştir:
C++:
int get_Item_SubType_Value(unsigned int type_value, string inputString)

ClientManager.cpp
ara :
C++:
                if (!(thecore_heart->pulse % thecore_heart->passes_per_sec * 10))

değiştir:
C++:
                if (!(thecore_heart->pulse % thecore_heart->passes_per_sec && 10))
bende warning vermiyor;

C++:
if (nullptr == ch || nullptr == aItemPoses)
{
    return false;
}
Bende bu şekilde
C++:
bool DSManager::DoRefineGrade(LPCHARACTER ch, TItemPos (&aItemPoses)[DRAGON_SOUL_REFINE_GRID_SIZE])
{
    if (NULL == ch)
        return false;

    if (NULL == aItemPoses)
    {
        return false;
    }
 
BUNLARI DENERMİSİN

panama.cpp
arat :
C++:
        char szIVFileName[256];

değiştir:
C++:
        char szIVFileName[263];

ProtoReader.cpp
ara :
C++:
int get_Item_SubType_Value(int type_value, string inputString)

değiştir:
C++:
int get_Item_SubType_Value(unsigned int type_value, string inputString)

ClientManager.cpp
ara :
C++:
                if (!(thecore_heart->pulse % thecore_heart->passes_per_sec * 10))

değiştir:
C++:
                if (!(thecore_heart->pulse % thecore_heart->passes_per_sec && 10))
 
En son bir moderatör tarafından düzenlenmiş:
Çözüm
BUNLARI DENERMİSİN

panama.cpp
arat :
char szIVFileName[256];

değiştir:
char szIVFileName[263];

ProtoReader.cpp
ara :
int get_Item_SubType_Value(int type_value, string inputString)

değiştir:
int get_Item_SubType_Value(unsigned int type_value, string inputString)

ClientManager.cpp
ara :
if (!(thecore_heart->pulse % thecore_heart->passes_per_sec * 10))

değiştir:
if (!(thecore_heart->pulse % thecore_heart->passes_per_sec && 10))
ProtoReader ile ClientManageri halletmiştim yapacak arkadaşlar sadece ProtoReader.cpp'den değil .h dosyasındanda aynısını uygulasınlar
Panama işe yaradı yardımın için teşekkürler.
 
Kod:
DragonSoul.cpp: In member function 'bool DSManager::DoRefineGrade(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:510:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  510 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStep(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:670:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  670 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStrength(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:831:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  831 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineGrade(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:510:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  510 |  if (NULL == aItemPoses)
      |  ^~
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStep(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:670:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  670 |  if (NULL == aItemPoses)
      |  ^~
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStrength(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:831:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  831 |  if (NULL == aItemPoses)
      |  ^~

Bu warning hala duruyor..
 
Kod:
DragonSoul.cpp: In member function 'bool DSManager::DoRefineGrade(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:510:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  510 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStep(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:670:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  670 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStrength(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:831:11: warning: the compiler can assume that the address of 'aItemPoses' will never be NULL [-Waddress]
  831 |  if (NULL == aItemPoses)
      |           ^
DragonSoul.cpp: In member function 'bool DSManager::DoRefineGrade(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:510:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  510 |  if (NULL == aItemPoses)
      |  ^~
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStep(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:670:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  670 |  if (NULL == aItemPoses)
      |  ^~
DragonSoul.cpp: In member function 'bool DSManager::DoRefineStrength(LPCHARACTER, TItemPos (&)[15])':
DragonSoul.cpp:831:2: warning: 'nonnull' argument 'aItemPoses' compared to NULL [-Wnonnull-compare]
  831 |  if (NULL == aItemPoses)
      |  ^~

Bu warning hala duruyor..
if (NULL == aItemPoses) bunları silebilirsin
 
Geri
Üst