From d52d30566f248fb6bd7b43dd4b7db76a26e02ea3 Mon Sep 17 00:00:00 2001
From: Gabriele Contini <contini.mailing@gmail.com>
Date: 周六, 14 12月 2019 14:23:27 +0800
Subject: [PATCH] fix codacy warnings

---
 CONTRIBUTING.md              |    6 +++---
 README.md                    |    6 +++---
 src/library/pc-identifiers.c |   11 +++++------
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index df84870..074e63a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -70,7 +70,7 @@
  
 #### General coding rules
 
-Supposing you already know how to contribute to an open source project on GitHub (if you have doubts you can check this short [guide](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project) ), you're working on an existing issue the code is already committed on your fork. 
+Supposing you already know how to contribute to an open source project on GitHub (if you have doubts you can check this short [guide](https://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project) ), you're working on an existing issue the code is already committed on your fork.
 
 *  Ensure your feature branch is up to date with the `develop`, eventually merge the latest changes from the `develop` branch. This will help us save time.
 *  Reformat the changed code using "clang-format" to keep consistent formatting style. The style we use is in `.clang-format` at the base of the project.
@@ -81,7 +81,7 @@
 ##### Don't
 *  Don't reformat the code following your personal likes, it introduce a lot of "noise" and makes very hard to merge. Use the clang-format style provided at the base of the project.
 *  Very large pull requests with few comments, no corresponding issue explaining what's it about will probably be rejected.
-    *  We understand that the project is still in beta stage, however we would like to discuss it with you before we take project changing decision. Please contact the project maintainer at `contini.mailing[AT]gmail.com` if you have time and plan to do a large contribution.
-    *  Even it it's in beta stage it's used ( _by some really courageous people!_ ) in production. We can't break current functionality, user established habits without documenting the change.
+   *  We understand that the project is still in beta stage, however we would like to discuss it with you before we take project changing decision. Please contact the project maintainer at `contini.mailing[AT]gmail.com` if you have time and plan to do a large contribution.
+   *  Even it it's in beta stage it's used ( _by some really courageous people!_ ) in production. We can't break current functionality, user established habits without documenting the change.
 
   
\ No newline at end of file
diff --git a/README.md b/README.md
index c10ad1c..9aeba93 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
 A copy protection, licensing software written in C++ for Windows and Linux (with a simple C api for use in C projects).
 
 [![Standard](https://img.shields.io/badge/c%2B%2B-11-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
-[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
+[![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)
 [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
 [![Build Status](https://travis-ci.org/open-license-manager/open-license-manager.svg?branch=develop)](https://travis-ci.org/open-license-manager/open-license-manager)
 [![Codacy Badge](https://api.codacy.com/project/badge/Grade/62d6e1bb22d648bd85b6f3bc344a545a)](https://www.codacy.com/manual/gcontini/open-license-manager?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=open-license-manager/open-license-manager&amp;utm_campaign=Badge_Grade)
@@ -25,11 +25,11 @@
  
 The following modules are planned...
 *  a license [backoffice](../../issues/7) in php (in order to handle multiple licenses).
-*  a license debugger to be sent to the final customer when there are licensing problems. 
+*  a license debugger to be sent to the final customer when there are licensing problems.
 *  a [log descriptor](../../issues/8) in order to decrypt logs generated by the license system.
 
 # How to build
-Below an overview of the basic build procedure, you can find detailed instructions for [linux](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) or [windows](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library-win) in the wiki. 
+Below an overview of the basic build procedure, you can find detailed instructions for [linux](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) or [windows](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library-windows) in the wiki. 
 
 ## Prerequisites
 *  Operating system: Linux(Ubuntu, CentOS), Windows
diff --git a/src/library/pc-identifiers.c b/src/library/pc-identifiers.c
index 0edb7ef..f1ec089 100644
--- a/src/library/pc-identifiers.c
+++ b/src/library/pc-identifiers.c
@@ -90,7 +90,6 @@
 
 static FUNCTION_RETURN generate_ethernet_pc_id(PcIdentifier *identifiers, unsigned int *num_identifiers, int use_mac) {
 	FUNCTION_RETURN result_adapterInfos;
-	unsigned int j, k;
 	OsAdapterInfo *adapterInfos;
 	size_t defined_adapters, adapters = 0;
 
@@ -105,7 +104,9 @@
 		adapterInfos = (OsAdapterInfo *)malloc(adapters * sizeof(OsAdapterInfo));
 		result_adapterInfos = getAdapterInfos(adapterInfos, &adapters);
 		if (result_adapterInfos == FUNC_RET_BUFFER_TOO_SMALL || result_adapterInfos == FUNC_RET_OK) {
+			unsigned int j;
 			for (j = 0; j < adapters; j++) {
+				unsigned int k;
 				for (k = 0; k < 6; k++)
 					if (use_mac) {
 						identifiers[j][k] = adapterInfos[j].mac_address[k + 2];
@@ -131,7 +132,6 @@
 	FUNCTION_RETURN result_diskinfos;
 	unsigned int i, j;
 	int defined_identifiers;
-	char firstChar;
 	DiskInfo *diskInfos;
 
 	result_diskinfos = getDiskInfos(NULL, &disk_num);
@@ -146,7 +146,7 @@
 		return result_diskinfos;
 	}
 	for (i = 0; i < disk_num; i++) {
-		firstChar = use_label ? diskInfos[i].label[0] : diskInfos[i].disk_sn[0];
+		char firstChar = use_label ? diskInfos[i].label[0] : diskInfos[i].disk_sn[0];
 		available_disk_info += firstChar == 0 ? 0 : 1;
 	}
 
@@ -241,15 +241,14 @@
 	static char Res[3];  // CRC Result
 	char CRC[2];
 	int i;
-	char DoInvert;
 
 	for (i = 0; i < 2; ++i) CRC[i] = 0;  // Init before calculation
 
 	for (i = 0; i < strlen(BitString); ++i) {
-		DoInvert = ('1' == BitString[i]) ^ CRC[1];  // XOR required?
+		char doInvert = ('1' == BitString[i]) ^ CRC[1];  // XOR required?
 
 		CRC[1] = CRC[0];
-		CRC[0] = DoInvert;
+		CRC[0] = doInvert;
 	}
 
 	for (i = 0; i < 2; ++i) Res[1 - i] = CRC[i] ? '1' : '0';  // Convert binary to ASCII

--
Gitblit v1.9.1