mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 04:43:03 +03:00
Fix some clang++ warnings.
Compiling with clang++ at the default warning/error levels produces some interesting warnings. Here's a pair of fixes for the simplest instances: moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp:133:7: warning: comparison of array 'path' equal to a null pointer is always false [-Wtautological-pointer-compare] if (path == NULL) { ^~~~ ~~~~ (The code unnecessarily checks that an automatic variable has a non-null address). moses/TranslationModel/DynSAInclude/onlineRLM.h:305:20: warning: unsequenced modification and access to 'den_val' [-Wunsequenced] if(((den_val = query(&ngram[len - num_fnd], num_fnd - 1)) > 0) && ^ (The code tries to cram too much into an "if" condition.)
This commit is contained in:
parent
54e55f2dcb
commit
464615a0c3
@ -302,7 +302,8 @@ float OnlineRLM<T>::getProb(const wordID_t* ngram, int len,
|
|||||||
}
|
}
|
||||||
while(num_fnd > 1) { // get lower order count
|
while(num_fnd > 1) { // get lower order count
|
||||||
//get sub-context of size one less than length found (exluding target)
|
//get sub-context of size one less than length found (exluding target)
|
||||||
if(((den_val = query(&ngram[len - num_fnd], num_fnd - 1)) > 0) &&
|
den_val = query(&ngram[len - num_fnd], num_fnd - 1);
|
||||||
|
if((den_val > 0) &&
|
||||||
(den_val >= in[len - num_fnd]) && (in[len - num_fnd] > 0)) {
|
(den_val >= in[len - num_fnd]) && (in[len - num_fnd] > 0)) {
|
||||||
break;
|
break;
|
||||||
} else --num_fnd; // else backoff to lower ngram order
|
} else --num_fnd; // else backoff to lower ngram order
|
||||||
|
@ -130,10 +130,6 @@ int removedirectoryrecursively(const char *dirname)
|
|||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
fprintf(stderr, "Out of memory error\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
dir = opendir(dirname);
|
dir = opendir(dirname);
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
perror("Error opendir()");
|
perror("Error opendir()");
|
||||||
|
Loading…
Reference in New Issue
Block a user