]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib: correctly set altitude unit without erasing neighbouring data
authorVincent Bernat <vincent.bernat@dailymotion.com>
Wed, 24 Jul 2013 16:33:51 +0000 (18:33 +0200)
committerVincent Bernat <vincent.bernat@dailymotion.com>
Wed, 24 Jul 2013 16:33:51 +0000 (18:33 +0200)
The way the altitude unit was set in buffer was erasing 4 unrelated
bits with 0. This made the altitude precision wrong.

src/lib/atom-private.c

index efb18f42ba8b83266d01e5df58d3aabd6f37e2c9..1516dbca16f258278c9439d52a1d7d196f98d7d9 100644 (file)
@@ -1877,7 +1877,8 @@ _lldpctl_atom_set_int_med_location(lldpctl_atom_t *atom, lldpctl_key_t key,
                case 0:
                case LLDP_MED_LOCATION_ALTITUDE_UNIT_METER:
                case LLDP_MED_LOCATION_ALTITUDE_UNIT_FLOOR:
-                       mloc->location->data[10] = value << 4;
+                       mloc->location->data[10] &= 0x0f;
+                       mloc->location->data[10] |= value << 4;
                        return atom;
                default: goto bad;
                }