Skip to content

Commit

Permalink
Avoiding overzealous warnings by performing explicit casts to const
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoSteemers committed Mar 21, 2013
1 parent a9b97a3 commit e2355f2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,14 +59,5 @@ Low priotity:
- Determining the difference between a 'thumb drive' and external storage hard disks - Determining the difference between a 'thumb drive' and external storage hard disks
- Configuration options for ignoring external storage hard disks or 'thumb drives' - Configuration options for ignoring external storage hard disks or 'thumb drives'


## Note on building
When building the project with the attached Makefile, a warning should show, like the following:

../code/daemon.c: In function ‘main’:
../code/daemon.c:21:2: warning: passing argument 1 of ‘processArguments’ from incompatible pointer type [enabled by default]
../code/processArguments.h:1:6: note: expected ‘const char * const*’ but argument is of type ‘char **’

This is not a problem in this case. If you want to know why, you can read about it [here, on StackOverflow](http://stackoverflow.com/questions/12992407/warning-when-passing-non-const-parameter-to-a-function-that-expects-const-parame).

## License ## License
This program is distributed under the terms of the GNU General Public License. A version of this license should have been provided with the program. It can also be found on: [http://www.gnu.org/licenses/gpl-3.0.txt](http://www.gnu.org/licenses/gpl-3.0.txt) This program is distributed under the terms of the GNU General Public License. A version of this license should have been provided with the program. It can also be found on: [http://www.gnu.org/licenses/gpl-3.0.txt](http://www.gnu.org/licenses/gpl-3.0.txt)
4 changes: 2 additions & 2 deletions code/backup.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ void backDeviceUp(char* mountPoint, char* deviceId)
int needsWhitelisting = 0; int needsWhitelisting = 0;
if(gBlacklist[0] != NULL) if(gBlacklist[0] != NULL)
{ {
blacklisted = contains(gBlacklist, deviceId); blacklisted = contains((const char * const *)gBlacklist, deviceId);
} }
if(gWhitelist[0] != NULL) if(gWhitelist[0] != NULL)
{ {
needsWhitelisting = 1; needsWhitelisting = 1;
whitelisted = contains(gWhitelist, deviceId); whitelisted = contains((const char * const *)gWhitelist, deviceId);
} }
if((blacklisted == 1) && (whitelisted == 1)) if((blacklisted == 1) && (whitelisted == 1))
{ {
Expand Down
2 changes: 1 addition & 1 deletion code/daemon.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {


/* Initialization of the daemon functionality */ /* Initialization of the daemon functionality */
initializeDeviceBookKeeping(); initializeDeviceBookKeeping();
processArguments(argv, argc); processArguments((const char * const *)argv, argc);
if(gTargetDirectory == NULL) if(gTargetDirectory == NULL)
{ {
syslog(LOG_ERR, "Exiting with failure: No target directory has been specified. Specifying a target directory is mandatory."); syslog(LOG_ERR, "Exiting with failure: No target directory has been specified. Specifying a target directory is mandatory.");
Expand Down
2 changes: 1 addition & 1 deletion code/daemonWindows.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) {


/* Initialization of the daemon functionality */ /* Initialization of the daemon functionality */
initializeDeviceBookKeeping(); initializeDeviceBookKeeping();
processArguments(argv, argc); processArguments((const char * const *)argv, argc);
if(gTargetDirectory == NULL) if(gTargetDirectory == NULL)
{ {
syslog(LOG_ERR, "Exiting with failure: No target directory has been specified. Specifying a target directory is mandatory."); syslog(LOG_ERR, "Exiting with failure: No target directory has been specified. Specifying a target directory is mandatory.");
Expand Down

0 comments on commit e2355f2

Please sign in to comment.