Jump to content
  • 0

Compilation warnings on Centos, how to get rid of them?


Technoken

Question


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

I'm currently having these warnings on Centos 6 when I recompile. But on windows I didn't get any warning

 

This warning is from the 'flag' at Shop to disable Discount & Overcharge

npc.c: In function ‘npc_parse_shop’:
npc.c:2674: warning: ‘id’ may be used uninitialized in this function
			nd->u.shop.count = 0;
			while ( p ) {
				unsigned short nameid2, qty = 0;
				int value;
LINE 2670			struct item_data* id;
				bool skip = false;
		
				if( p == NULL )
					break;
				switch(type) {
					case NPCTYPE_MARKETSHOP:
		#if PACKETVER >= 20131223
						if (sscanf(p, ",%6hu:%11d:%6hu", &nameid2, &value, &qty) != 3) {
							// Set shop flag [Cydh]
							if (nameid2 != 0) {
								ShowInfo("Shop at '"CL_WHITE"%s#L%d"CL_RESET"' Discount: "CL_WHITE"%s"CL_RESET", Overcharge: "CL_WHITE"%s"CL_RESET".\n",
									filepath, strline(buffer,start-buffer), nameid2&1 ? "NO" : "YES", nameid2&2 ? "NO" : "YES");
								nd->u.shop.flag = (unsigned char)nameid2;
							}
							if (!nd->u.shop.flag) {
								ShowError("npc_parse_shop: (MARKETSHOP) Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
								skip = true;
							}
						}
		#endif
						break;
					default:
						if (sscanf(p, ",%6hu:%11d", &nameid2, &value) != 2) {
							// Set shop flag [Cydh]
							if (nameid2 != 0) {
								ShowInfo("Shop at '"CL_WHITE"%s#L%d"CL_RESET"' Discount: "CL_WHITE"%s"CL_RESET", Overcharge: "CL_WHITE"%s"CL_RESET".\n",
									filepath, strline(buffer,start-buffer), nameid2&1 ? "NO" : "YES", nameid2&2 ? "NO" : "YES");
								nd->u.shop.flag = (unsigned char)nameid2;
							}
							if (!nd->u.shop.flag) {
								ShowError("npc_parse_shop: Invalid item definition in file '%s', line '%d'. Ignoring the rest of the line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
								skip = true;
							}
						}
						break;
				}

 


This one is from  bOneShootOneKill mod

pc.c: In function ‘pc_bonus’:
pc.c:3105: warning: statement with no effect
pc.c: In function ‘pc_bonus2’:
pc.c:3804: warning: statement with no effect
pc.c:3818: warning: statement with no effect
3102		case SP_SUB_ONESHOOTONEKILL: // [Cydh]
3103			if (sd->state.lr_flag != 2) {
3104				sd->bonus.sub_oneshootonekill += val;
3105				cap_value(sd->bonus.sub_oneshootonekill,-10000,10000);
3106			}
3107			break;
//----------------------------------------------------------------------
3800			for (i = 0; i < len; i++) {
3801				if (sd->oneshootonekill_mob[i].mob_id == type2) {
3802					sd->oneshootonekill_mob[i].rate += val;
3803					isAdded = true;
3804					cap_value(sd->oneshootonekill_mob[i].rate, -10000, 10000);
3805					break;
3806				}
3807			}
//-------------------------------------------------------------------------
3816			sd->oneshootonekill_mob[i].mob_id = type2;
3817			sd->oneshootonekill_mob[i].rate = val;
3818			cap_value(sd->oneshootonekill_mob[i].rate, -10000, 10000);
3819		}

 

EDIT:

So here's what I did to get rid of these warnings

On npc.c, I replaced struct item_data* id; with struct item_data* id = itemdb_exists(nameid2);

and on pc.c I replaced these lines:

cap_value(sd->bonus.sub_oneshootonekill,-10000,10000); to sd->bonus.sub_oneshootonekill = cap_value(sd->bonus.sub_oneshootonekill,-10000,10000);

cap_value(sd->oneshootonekill_mob.rate, -10000, 10000); to sd->oneshootonekill_mob.rate = cap_value(sd->oneshootonekill_mob.rate, -10000, 10000);

I hope somehow could correct me if I did it wrong, since I just know little about src.

Edited by Technoken
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...