s390/zcrypt: fix smatch warnings
authorHarald Freudenberger <freude@linux.ibm.com>
Tue, 30 Jun 2020 07:54:50 +0000 (09:54 +0200)
committerHeiko Carstens <heiko.carstens@de.ibm.com>
Fri, 3 Jul 2020 08:49:27 +0000 (10:49 +0200)
Fix these smatch warnings:

zcrypt_api.c:986 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'pref_weight'.
zcrypt_api.c:1008 _zcrypt_send_ep11_cprb() error: uninitialized symbol 'weight'.
zcrypt_api.c:676 zcrypt_rsa_modexpo() error: uninitialized symbol 'pref_weight'.
zcrypt_api.c:694 zcrypt_rsa_modexpo() error: uninitialized symbol 'weight'.
zcrypt_api.c:760 zcrypt_rsa_crt() error: uninitialized symbol 'pref_weight'.
zcrypt_api.c:778 zcrypt_rsa_crt() error: uninitialized symbol 'weight'.
zcrypt_api.c:824 _zcrypt_send_cprb() warn: always true condition '(tdom >= 0) => (0-u16max >= 0)'
zcrypt_api.c:846 _zcrypt_send_cprb() error: uninitialized symbol 'pref_weight'.
zcrypt_api.c:867 _zcrypt_send_cprb() error: uninitialized symbol 'weight'.
zcrypt_api.c:1065 zcrypt_rng() error: uninitialized symbol 'pref_weight'.
zcrypt_api.c:1079 zcrypt_rng() error: uninitialized symbol 'weight'.
zcrypt_cex4.c:251 ep11_card_op_modes_show() warn: should '(1 << ep11_op_modes[i]->mode_bit)' be a 64 bit type?
zcrypt_cex4.c:346 ep11_queue_op_modes_show() warn: should '(1 << ep11_op_modes[i]->mode_bit)' be a 64 bit type?

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
drivers/s390/crypto/zcrypt_api.c
drivers/s390/crypto/zcrypt_cex4.c

index 56a405dce8bcf32c468443d5249ce466285d999c..7775ff84f22382eee2248f18007b2f15c2ff2565 100644 (file)
@@ -634,7 +634,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
 {
        struct zcrypt_card *zc, *pref_zc;
        struct zcrypt_queue *zq, *pref_zq;
-       unsigned int weight, pref_weight;
+       unsigned int weight = 0, pref_weight = 0;
        unsigned int func_code;
        int qid = 0, rc = -ENODEV;
        struct module *mod;
@@ -718,7 +718,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
 {
        struct zcrypt_card *zc, *pref_zc;
        struct zcrypt_queue *zq, *pref_zq;
-       unsigned int weight, pref_weight;
+       unsigned int weight = 0, pref_weight = 0;
        unsigned int func_code;
        int qid = 0, rc = -ENODEV;
        struct module *mod;
@@ -803,7 +803,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms,
        struct zcrypt_card *zc, *pref_zc;
        struct zcrypt_queue *zq, *pref_zq;
        struct ap_message ap_msg;
-       unsigned int weight, pref_weight;
+       unsigned int weight = 0, pref_weight = 0;
        unsigned int func_code;
        unsigned short *domain, tdom;
        int qid = 0, rc = -ENODEV;
@@ -822,7 +822,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms,
         * domain but a control only domain, use the default domain as target.
         */
        tdom = *domain;
-       if (tdom >= 0 && tdom < AP_DOMAINS &&
+       if (tdom < AP_DOMAINS &&
            !ap_test_config_usage_domain(tdom) &&
            ap_test_config_ctrl_domain(tdom) &&
            ap_domain_index >= 0)
@@ -931,7 +931,7 @@ static long _zcrypt_send_ep11_cprb(struct ap_perms *perms,
        struct zcrypt_queue *zq, *pref_zq;
        struct ep11_target_dev *targets;
        unsigned short target_num;
-       unsigned int weight, pref_weight;
+       unsigned int weight = 0, pref_weight = 0;
        unsigned int func_code;
        struct ap_message ap_msg;
        int qid = 0, rc = -ENODEV;
@@ -1040,7 +1040,7 @@ static long zcrypt_rng(char *buffer)
 {
        struct zcrypt_card *zc, *pref_zc;
        struct zcrypt_queue *zq, *pref_zq;
-       unsigned int weight, pref_weight;
+       unsigned int weight = 0, pref_weight = 0;
        unsigned int func_code;
        struct ap_message ap_msg;
        unsigned int domain;
index cdaa8348ad0412226998f2a721c1afd6871cad11..337ec71ddb5895097bcf8d8ad1cd6702c9c9cac6 100644 (file)
@@ -250,7 +250,7 @@ static ssize_t ep11_card_op_modes_show(struct device *dev,
        ep11_get_card_info(ac->id, &ci, zc->online);
 
        for (i = 0; ep11_op_modes[i].mode_txt; i++) {
-               if (ci.op_mode & (1 << ep11_op_modes[i].mode_bit)) {
+               if (ci.op_mode & (1ULL << ep11_op_modes[i].mode_bit)) {
                        if (n > 0)
                                buf[n++] = ' ';
                        n += scnprintf(buf + n, PAGE_SIZE - n,
@@ -345,7 +345,7 @@ static ssize_t ep11_queue_op_modes_show(struct device *dev,
                                     &di);
 
        for (i = 0; ep11_op_modes[i].mode_txt; i++) {
-               if (di.op_mode & (1 << ep11_op_modes[i].mode_bit)) {
+               if (di.op_mode & (1ULL << ep11_op_modes[i].mode_bit)) {
                        if (n > 0)
                                buf[n++] = ' ';
                        n += scnprintf(buf + n, PAGE_SIZE - n,