diff options
| author | Paul Eggert | 2011-05-23 18:59:17 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-05-23 18:59:17 -0700 |
| commit | 2d1fc3c73cd8b771cbfb1114f7f85dc0273d24e3 (patch) | |
| tree | 15889e3086ebad411afab40a167690f802651ec6 /src/dbusbind.c | |
| parent | c8a9ca5a6456e7d0ec9577493d5110b692b818bf (diff) | |
| download | emacs-2d1fc3c73cd8b771cbfb1114f7f85dc0273d24e3.tar.gz emacs-2d1fc3c73cd8b771cbfb1114f7f85dc0273d24e3.zip | |
* dbusbind.c: Use XFASTINT rather than XUINT, and check for nonneg.
(Fdbus_call_method, Fdbus_call_method_asynchronously):
Use XFASTINT rather than XUINT when numbers are nonnegative.
(xd_append_arg, Fdbus_method_return_internal):
(Fdbus_method_error_internal): Likewise. Also, for unsigned
arguments, check that Lisp number is nonnegative, rather than
silently wrapping negative numbers around.
Diffstat (limited to 'src/dbusbind.c')
| -rw-r--r-- | src/dbusbind.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c index 80c52dc3bd0..0de30613801 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -431,9 +431,9 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 431 | switch (dtype) | 431 | switch (dtype) |
| 432 | { | 432 | { |
| 433 | case DBUS_TYPE_BYTE: | 433 | case DBUS_TYPE_BYTE: |
| 434 | CHECK_NUMBER (object); | 434 | CHECK_NATNUM (object); |
| 435 | { | 435 | { |
| 436 | unsigned char val = XUINT (object) & 0xFF; | 436 | unsigned char val = XFASTINT (object) & 0xFF; |
| 437 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 437 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); |
| 438 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 438 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 439 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 439 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -460,9 +460,9 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | case DBUS_TYPE_UINT16: | 462 | case DBUS_TYPE_UINT16: |
| 463 | CHECK_NUMBER (object); | 463 | CHECK_NATNUM (object); |
| 464 | { | 464 | { |
| 465 | dbus_uint16_t val = XUINT (object); | 465 | dbus_uint16_t val = XFASTINT (object); |
| 466 | XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); | 466 | XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); |
| 467 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 467 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 468 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 468 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -483,9 +483,9 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 483 | #ifdef DBUS_TYPE_UNIX_FD | 483 | #ifdef DBUS_TYPE_UNIX_FD |
| 484 | case DBUS_TYPE_UNIX_FD: | 484 | case DBUS_TYPE_UNIX_FD: |
| 485 | #endif | 485 | #endif |
| 486 | CHECK_NUMBER (object); | 486 | CHECK_NATNUM (object); |
| 487 | { | 487 | { |
| 488 | dbus_uint32_t val = XUINT (object); | 488 | dbus_uint32_t val = XFASTINT (object); |
| 489 | XD_DEBUG_MESSAGE ("%c %u", dtype, val); | 489 | XD_DEBUG_MESSAGE ("%c %u", dtype, val); |
| 490 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 490 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 491 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 491 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -503,10 +503,10 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | case DBUS_TYPE_UINT64: | 505 | case DBUS_TYPE_UINT64: |
| 506 | CHECK_NUMBER (object); | 506 | CHECK_NATNUM (object); |
| 507 | { | 507 | { |
| 508 | dbus_uint64_t val = XUINT (object); | 508 | dbus_uint64_t val = XFASTINT (object); |
| 509 | XD_DEBUG_MESSAGE ("%c %"pI"u", dtype, XUINT (object)); | 509 | XD_DEBUG_MESSAGE ("%c %"pI"d", dtype, XFASTINT (object)); |
| 510 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 510 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 511 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 511 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 512 | return; | 512 | return; |
| @@ -1110,7 +1110,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1110 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) | 1110 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) |
| 1111 | { | 1111 | { |
| 1112 | CHECK_NATNUM (args[i+1]); | 1112 | CHECK_NATNUM (args[i+1]); |
| 1113 | timeout = XUINT (args[i+1]); | 1113 | timeout = XFASTINT (args[i+1]); |
| 1114 | i = i+2; | 1114 | i = i+2; |
| 1115 | } | 1115 | } |
| 1116 | 1116 | ||
| @@ -1186,7 +1186,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1186 | 1186 | ||
| 1187 | /* Return the result. If there is only one single Lisp object, | 1187 | /* Return the result. If there is only one single Lisp object, |
| 1188 | return it as-it-is, otherwise return the reversed list. */ | 1188 | return it as-it-is, otherwise return the reversed list. */ |
| 1189 | if (XUINT (Flength (result)) == 1) | 1189 | if (XFASTINT (Flength (result)) == 1) |
| 1190 | RETURN_UNGCPRO (CAR_SAFE (result)); | 1190 | RETURN_UNGCPRO (CAR_SAFE (result)); |
| 1191 | else | 1191 | else |
| 1192 | RETURN_UNGCPRO (Fnreverse (result)); | 1192 | RETURN_UNGCPRO (Fnreverse (result)); |
| @@ -1292,7 +1292,7 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1292 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) | 1292 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) |
| 1293 | { | 1293 | { |
| 1294 | CHECK_NATNUM (args[i+1]); | 1294 | CHECK_NATNUM (args[i+1]); |
| 1295 | timeout = XUINT (args[i+1]); | 1295 | timeout = XFASTINT (args[i+1]); |
| 1296 | i = i+2; | 1296 | i = i+2; |
| 1297 | } | 1297 | } |
| 1298 | 1298 | ||
| @@ -1382,11 +1382,11 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1382 | serial = args[1]; | 1382 | serial = args[1]; |
| 1383 | service = args[2]; | 1383 | service = args[2]; |
| 1384 | 1384 | ||
| 1385 | CHECK_NUMBER (serial); | 1385 | CHECK_NATNUM (serial); |
| 1386 | CHECK_STRING (service); | 1386 | CHECK_STRING (service); |
| 1387 | GCPRO3 (bus, serial, service); | 1387 | GCPRO3 (bus, serial, service); |
| 1388 | 1388 | ||
| 1389 | XD_DEBUG_MESSAGE ("%"pI"u %s ", XUINT (serial), SDATA (service)); | 1389 | XD_DEBUG_MESSAGE ("%"pI"d %s ", XFASTINT (serial), SSDATA (service)); |
| 1390 | 1390 | ||
| 1391 | /* Open a connection to the bus. */ | 1391 | /* Open a connection to the bus. */ |
| 1392 | connection = xd_initialize (bus, TRUE); | 1392 | connection = xd_initialize (bus, TRUE); |
| @@ -1394,7 +1394,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1394 | /* Create the message. */ | 1394 | /* Create the message. */ |
| 1395 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); | 1395 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); |
| 1396 | if ((dmessage == NULL) | 1396 | if ((dmessage == NULL) |
| 1397 | || (!dbus_message_set_reply_serial (dmessage, XUINT (serial))) | 1397 | || (!dbus_message_set_reply_serial (dmessage, XFASTINT (serial))) |
| 1398 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) | 1398 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) |
| 1399 | { | 1399 | { |
| 1400 | UNGCPRO; | 1400 | UNGCPRO; |
| @@ -1470,11 +1470,11 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1470 | serial = args[1]; | 1470 | serial = args[1]; |
| 1471 | service = args[2]; | 1471 | service = args[2]; |
| 1472 | 1472 | ||
| 1473 | CHECK_NUMBER (serial); | 1473 | CHECK_NATNUM (serial); |
| 1474 | CHECK_STRING (service); | 1474 | CHECK_STRING (service); |
| 1475 | GCPRO3 (bus, serial, service); | 1475 | GCPRO3 (bus, serial, service); |
| 1476 | 1476 | ||
| 1477 | XD_DEBUG_MESSAGE ("%"pI"u %s ", XUINT (serial), SDATA (service)); | 1477 | XD_DEBUG_MESSAGE ("%"pI"d %s ", XFASTINT (serial), SSDATA (service)); |
| 1478 | 1478 | ||
| 1479 | /* Open a connection to the bus. */ | 1479 | /* Open a connection to the bus. */ |
| 1480 | connection = xd_initialize (bus, TRUE); | 1480 | connection = xd_initialize (bus, TRUE); |
| @@ -1483,7 +1483,7 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1483 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); | 1483 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); |
| 1484 | if ((dmessage == NULL) | 1484 | if ((dmessage == NULL) |
| 1485 | || (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED)) | 1485 | || (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED)) |
| 1486 | || (!dbus_message_set_reply_serial (dmessage, XUINT (serial))) | 1486 | || (!dbus_message_set_reply_serial (dmessage, XFASTINT (serial))) |
| 1487 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) | 1487 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) |
| 1488 | { | 1488 | { |
| 1489 | UNGCPRO; | 1489 | UNGCPRO; |